1 //===- Path.cpp - Path Operating System Concept -----------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // Copyright (C) 2004 eXtensible Systems, Inc. All Rights Reserved.
7 // This program is open source software; you can redistribute it and/or modify
8 // it under the terms of the University of Illinois Open Source License. See
9 // LICENSE.TXT (distributed with this software) for details.
11 // This program is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE.
15 //===----------------------------------------------------------------------===//
17 // This file implements the common Path concept for a variety of platforms.
18 // A path is simply the name of some file system storage place. Paths can be
19 // either directories or files.
21 //===----------------------------------------------------------------------===//
22 /// @file lib/System/Path.cpp
23 /// @author Reid Spencer <raspencer@x10sys.com> (original author)
24 /// @version \verbatim $Id$ \endverbatim
27 /// @brief Defines the llvm::sys::Path class.
28 //===----------------------------------------------------------------------===//
30 #include "llvm/System/Path.h"
36 Path::append_directory( const std::string& dirname ) throw() {
37 this->append( dirname );
43 Path::append_file( const std::string& filename ) throw() {
44 this->append( filename );
49 Path::create( bool create_parents)throw() {
50 ErrorCode result ( NOT_AN_ERROR );
51 if ( is_directory() ) {
52 if ( create_parents ) {
53 result = this->create_directories( );
55 result = this->create_directory( );
57 } else if ( is_file() ) {
58 if ( create_parents ) {
59 result = this->create_directories( );
62 result = this->create_file( );
65 result = ErrorCode(ERR_SYS_INVALID_ARG);
71 Path::remove() throw() {
72 ErrorCode result( NOT_AN_ERROR );
73 if ( is_directory() ) {
75 this->remove_directory( );
76 } else if ( is_file() ) {
77 if ( exists() ) this->remove_file( );
79 result = ErrorCode(ERR_SYS_INVALID_ARG);
87 // Include the platform specific portions of this class
88 #include "linux/Path.cpp"
90 // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab