Synopsis - Cross-Reference
File: /src/Support/Path.hh1// 2// Copyright (C) 2004 Stefan Seefeld 3// All rights reserved. 4// Licensed to the public under the terms of the GNU LGPL (>= 2), 5// see the file COPYING for details. 6// 7 8#ifndef Synopsis_Path_hh_ 9#define Synopsis_Path_hh_ 10 11#include <string> 12#include <stdexcept> 13 14namespace Synopsis 15{ 16 17class Path 18{ 19public: 20 static const char SEPARATOR; 21 //. take a possibly relative path 22 //. and turn it into an absolute one. 23 Path(const std::string &from) : my_impl(from) {} 24 25 //. return the file component in the path 26 std::string basename() const; 27 //. return the directory component in the path 28 Path dirname() const; 29 //. return absolute path 30 Path abs() const { return Path(normalize(my_impl));} 31 //. strip prefix 32 void strip(const std::string &prefix); 33 //. return the path as a string 34 std::string str() const { return my_impl;} 35 //. return the current working directory 36 static std::string cwd(); 37private: 38 //. return the normalized and absolutized path 39 static std::string normalize(const std::string &); 40 std::string my_impl; 41}; 42 43//. create directory, makes all intermediate-level directories 44//. needed to contain the leaf directory. 45void makedirs(const Path &); 46 47} 48 49#endif