diff options
| author | Reid Spencer <rspencer@reidspencer.com> | 2004-08-29 05:24:01 +0000 |
|---|---|---|
| committer | Reid Spencer <rspencer@reidspencer.com> | 2004-08-29 05:24:01 +0000 |
| commit | 6df221d50a708110f8078d8226c16b5dca963ed1 (patch) | |
| tree | 267f602e06f428004ad44b1992f69093496920ef /llvm/lib/System/Path.cpp | |
| parent | c227d73e5fd83d6bad4ef392428db587b4ed31be (diff) | |
| download | bcm5719-llvm-6df221d50a708110f8078d8226c16b5dca963ed1.tar.gz bcm5719-llvm-6df221d50a708110f8078d8226c16b5dca963ed1.zip | |
Revise the design of the Path concept per peer review. Too many changes to
note individually but these essence of it is to not derive from
std::string, clarify the interface, and provide better documentation.
There is now also (untested) implementations for AIX, Darwin, and SunOS.
llvm-svn: 16078
Diffstat (limited to 'llvm/lib/System/Path.cpp')
| -rw-r--r-- | llvm/lib/System/Path.cpp | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/llvm/lib/System/Path.cpp b/llvm/lib/System/Path.cpp index e32842dd188..93c1e0a7100 100644 --- a/llvm/lib/System/Path.cpp +++ b/llvm/lib/System/Path.cpp @@ -10,10 +10,11 @@ // This header file implements the operating system Path concept. // //===----------------------------------------------------------------------===// + #include "llvm/System/Path.h" namespace llvm { -namespace sys { +using namespace sys; //===----------------------------------------------------------------------===// //=== WARNING: Implementation here must contain only TRULY operating system @@ -21,40 +22,18 @@ namespace sys { //===----------------------------------------------------------------------===// bool -Path::is_valid() const { - if ( empty() ) return false; - return true; -} - -void -Path::fill( char* buffer, unsigned bufflen ) const { - unsigned pathlen = length(); - assert( bufflen > pathlen && "Insufficient buffer size" ); - unsigned copylen = pathlen <? (bufflen - 1); - this->copy(buffer, copylen, 0 ); - buffer[ copylen ] = 0; +Path::is_file() const { + return (is_valid() && path[path.length()-1] != '/'); } -void -Path::make_directory() { - char end[2]; - end[0] = '/'; - end[1] = 0; - if ( empty() ) - this->assign( end ); - else if ( (*this)[length()-1] != '/') - this->append( end ); +bool +Path::is_directory() const { + return (is_valid() && path[path.length()-1] == '/'); } -void -Path::make_file() { - if ( (*this)[length()-1] == '/') - this->erase( this->length()-1, 1 ); } // Include the truly platform-specific parts of this class. #include "platform/Path.cpp" -} -} // vim: sw=2 |

