aboutsummaryrefslogtreecommitdiffstats
path: root/lib/System/Path.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-08-25 06:20:07 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-08-25 06:20:07 +0000
commitb89a2237ea79e0576fdb426b124f1940f53da159 (patch)
treebd6277d71a8627ffce532b7e1fefd49d3f310f78 /lib/System/Path.cpp
parent17f130c61e268b39044870b66b58d7575d7ba784 (diff)
downloadexternal_llvm-b89a2237ea79e0576fdb426b124f1940f53da159.zip
external_llvm-b89a2237ea79e0576fdb426b124f1940f53da159.tar.gz
external_llvm-b89a2237ea79e0576fdb426b124f1940f53da159.tar.bz2
Initial implementation of the Path operating system concept.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16048 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Path.cpp')
-rw-r--r--lib/System/Path.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/lib/System/Path.cpp b/lib/System/Path.cpp
new file mode 100644
index 0000000..e32842d
--- /dev/null
+++ b/lib/System/Path.cpp
@@ -0,0 +1,60 @@
+//===-- Path.cpp - Implement OS Path Concept --------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Reid Spencer and is distributed under the
+// University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This header file implements the operating system Path concept.
+//
+//===----------------------------------------------------------------------===//
+#include "llvm/System/Path.h"
+
+namespace llvm {
+namespace sys {
+
+//===----------------------------------------------------------------------===//
+//=== WARNING: Implementation here must contain only TRULY operating system
+//=== independent code.
+//===----------------------------------------------------------------------===//
+
+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;
+}
+
+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 );
+}
+
+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