aboutsummaryrefslogtreecommitdiffstats
path: root/lib/System/Path.cpp
blob: e32842dd18895012608a31723356349c4fcb235c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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