[llvm-commits] CVS: llvm/lib/System/ErrorCode.cpp Path.cpp
Reid Spencer
reid at x10sys.com
Sun Aug 15 01:14:43 PDT 2004
Changes in directory llvm/lib/System:
ErrorCode.cpp added (r1.1)
Path.cpp added (r1.1)
---
Log message:
Initial implementations of the ErrorCode and Path concepts for Linux.
---
Diffs of the changes: (+128 -0)
Index: llvm/lib/System/ErrorCode.cpp
diff -c /dev/null llvm/lib/System/ErrorCode.cpp:1.1
*** /dev/null Sun Aug 15 03:14:43 2004
--- llvm/lib/System/ErrorCode.cpp Sun Aug 15 03:14:33 2004
***************
*** 0 ****
--- 1,38 ----
+ //===- ErrorCode.cpp - Define the ErrorCode class ---------------*- C++ -*-===//
+ //
+ // Copyright (C) 2004 eXtensible Systems, Inc. All Rights Reserved.
+ //
+ // This program is open source software; you can redistribute it and/or modify
+ // it under the terms of the University of Illinois Open Source License. See
+ // LICENSE.TXT (distributed with this software) for details.
+ //
+ // This program is distributed in the hope that it will be useful, but
+ // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ // or FITNESS FOR A PARTICULAR PURPOSE.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // This file defines the members of the llvm::sys::ErrorCode class. This class
+ // is used to hold operating system and other error codes in a platform
+ // agnostic manner.
+ //
+ //===----------------------------------------------------------------------===//
+ /// @file lib/System/ErrorCode.h
+ /// @author Reid Spencer <raspencer at x10sys.com> (original author)
+ /// @version \verbatim $Id: ErrorCode.cpp,v 1.1 2004/08/15 08:14:33 reid Exp $ \endverbatim
+ /// @date 2004/08/14
+ /// @since 1.4
+ /// @brief Declares the llvm::sys::ErrorCode class.
+ //===----------------------------------------------------------------------===//
+
+ #include "llvm/System/ErrorCode.h"
+
+ namespace llvm {
+ namespace sys {
+
+ }
+ }
+
+ #include "linux/ErrorCode.cpp"
+
+ // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
Index: llvm/lib/System/Path.cpp
diff -c /dev/null llvm/lib/System/Path.cpp:1.1
*** /dev/null Sun Aug 15 03:14:43 2004
--- llvm/lib/System/Path.cpp Sun Aug 15 03:14:33 2004
***************
*** 0 ****
--- 1,90 ----
+ //===- Path.cpp - Path Operating System Concept -----------------*- C++ -*-===//
+ //
+ // The LLVM Compiler Infrastructure
+ //
+ // Copyright (C) 2004 eXtensible Systems, Inc. All Rights Reserved.
+ //
+ // This program is open source software; you can redistribute it and/or modify
+ // it under the terms of the University of Illinois Open Source License. See
+ // LICENSE.TXT (distributed with this software) for details.
+ //
+ // This program is distributed in the hope that it will be useful, but
+ // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ // or FITNESS FOR A PARTICULAR PURPOSE.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // This file implements the common Path concept for a variety of platforms.
+ // A path is simply the name of some file system storage place. Paths can be
+ // either directories or files.
+ //
+ //===----------------------------------------------------------------------===//
+ /// @file lib/System/Path.cpp
+ /// @author Reid Spencer <raspencer at x10sys.com> (original author)
+ /// @version \verbatim $Id: Path.cpp,v 1.1 2004/08/15 08:14:33 reid Exp $ \endverbatim
+ /// @date 2004/08/14
+ /// @since 1.4
+ /// @brief Defines the llvm::sys::Path class.
+ //===----------------------------------------------------------------------===//
+
+ #include "llvm/System/Path.h"
+
+ namespace llvm {
+ namespace sys {
+
+ ErrorCode
+ Path::append_directory( const std::string& dirname ) throw() {
+ this->append( dirname );
+ make_directory();
+ return NOT_AN_ERROR;
+ }
+
+ ErrorCode
+ Path::append_file( const std::string& filename ) throw() {
+ this->append( filename );
+ return NOT_AN_ERROR;
+ }
+
+ ErrorCode
+ Path::create( bool create_parents)throw() {
+ ErrorCode result ( NOT_AN_ERROR );
+ if ( is_directory() ) {
+ if ( create_parents ) {
+ result = this->create_directories( );
+ } else {
+ result = this->create_directory( );
+ }
+ } else if ( is_file() ) {
+ if ( create_parents ) {
+ result = this->create_directories( );
+ }
+ if ( result ) {
+ result = this->create_file( );
+ }
+ } else {
+ result = ErrorCode(ERR_SYS_INVALID_ARG);
+ }
+ return result;
+ }
+
+ ErrorCode
+ Path::remove() throw() {
+ ErrorCode result( NOT_AN_ERROR );
+ if ( is_directory() ) {
+ if ( exists() )
+ this->remove_directory( );
+ } else if ( is_file() ) {
+ if ( exists() ) this->remove_file( );
+ } else {
+ result = ErrorCode(ERR_SYS_INVALID_ARG);
+ }
+ return result;
+ }
+
+ }
+ }
+
+ // Include the platform specific portions of this class
+ #include "linux/Path.cpp"
+
+ // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
More information about the llvm-commits
mailing list