namespace
{
-/**
-Helper function to determine the location of the program's executable. Caches
-the last result to cut down filesystem access with repeated calls.
-*/
+/** Helper function to determine the location of the program's executable.
+Caches the last result to cut down filesystem access with repeated calls. */
const Path &get_bin_dir(const string &argv0)
{
static string last_argv0;
return a;
}
-/**
-Attaches another path to the end of this one. An absolute path replaces the
-existing data. ".." elements annihilate the last component and "." elements
-are ignored.
-*/
Path &Path::operator/=(const Path &p)
{
if(p.is_absolute())
}
}
-/**
-Adds a single component to the path, emulating the cd command. Fails horribly
-if comp contains a separator character.
-*/
void Path::add_component(const string &comp)
{
if(comp.empty())
Path operator/(const Path &p) const;
Path &operator/=(const Path &);
- /**
- Extracts a single component from the path. Negative indices count from the
- end of the path.
- */
+ /** Extracts a single component from the path. Negative indices count from
+ the end of the path. */
std::string operator[](int) const;
bool operator==(const Path &) const;
Iterator end() const;
private:
void init(const std::string &);
+
+ /** Adds a component to the path. It must not contain the directory
+ separator character. */
void add_component(const std::string &);
};
namespace Msp {
namespace FS {
-/**
-Gets information about a file. Returns 0 on success or -1 on error. This
+/** Gets information about a file. Returns 0 on success or -1 on error. This
version can be used to check for file existence and get information in one
-call.
-*/
+call. */
int stat(const Path &fn, struct stat &st);
-/**
-Returns information about a file. This version throws an exception if an error
-occurs.
-*/
+/** Returns information about a file. This version throws an exception if an
+error occurs. */
struct stat stat(const Path &fn);
/// Gets information about a file, without following symbolic links
/// Removes the last component from the path.
Path dirname(const Path &);
-/**
-Returns the base part of a filename. This includes everything up to the last
-dot, but not the dot itself.
-*/
+/** Returns the base part of a filename. This includes everything up to the
+last dot, but not the dot itself. */
std::string basepart(const std::string &);
-/**
-Returns the extension part of a filename. This includes the last dot and
-everything after it.
-*/
+/** Returns the extension part of a filename. This includes the last dot and
+everything after it. */
std::string extpart(const std::string &);
-/**
-Fixes the case of the given path to match files / directories on the
-filesystem.
-*/
+/// Fixes the case of a path to match files / directories on the filesystem.
Path fix_case(const Path &path);
/// Reads the contents of a symbolic link