blob: e32842dd18895012608a31723356349c4fcb235c [file] [log] [blame]
Reid Spencerb89a2232004-08-25 06:20:07 +00001//===-- Path.cpp - Implement OS Path Concept --------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Reid Spencer and is distributed under the
6// University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This header file implements the operating system Path concept.
11//
12//===----------------------------------------------------------------------===//
13#include "llvm/System/Path.h"
14
15namespace llvm {
16namespace sys {
17
18//===----------------------------------------------------------------------===//
19//=== WARNING: Implementation here must contain only TRULY operating system
20//=== independent code.
21//===----------------------------------------------------------------------===//
22
23bool
24Path::is_valid() const {
25 if ( empty() ) return false;
26 return true;
27}
28
29void
30Path::fill( char* buffer, unsigned bufflen ) const {
31 unsigned pathlen = length();
32 assert( bufflen > pathlen && "Insufficient buffer size" );
33 unsigned copylen = pathlen <? (bufflen - 1);
34 this->copy(buffer, copylen, 0 );
35 buffer[ copylen ] = 0;
36}
37
38void
39Path::make_directory() {
40 char end[2];
41 end[0] = '/';
42 end[1] = 0;
43 if ( empty() )
44 this->assign( end );
45 else if ( (*this)[length()-1] != '/')
46 this->append( end );
47}
48
49void
50Path::make_file() {
51 if ( (*this)[length()-1] == '/')
52 this->erase( this->length()-1, 1 );
53}
54
55// Include the truly platform-specific parts of this class.
56#include "platform/Path.cpp"
57}
58}
59
60// vim: sw=2