3 This file is part of libmspfs
4 Copyright © 2006-2008 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #ifndef MSP_FS_UTILS_H_
9 #define MSP_FS_UTILS_H_
16 /// Extracts the last component of the path.
17 std::string basename(const Path &);
19 /// Removes the last component from the path.
20 Path dirname(const Path &);
23 Returns the base part of a filename. This includes everything up to the last
24 dot, but not the dot itself.
26 std::string basepart(const std::string &);
29 Returns the extension part of a filename. This includes the last dot and
32 std::string extpart(const std::string &);
35 Fixes the case of the given path to match files / directories on the
38 Path fix_case(const Path &path);
40 /// Reads the contents of a symbolic link
41 Path readlink(const Path &path);
43 /// Resolves all symlinks from a path. Will always return an absolute path.
44 Path realpath(const Path &path);
47 void unlink(const Path &path);
49 /// Makes a path relative to some base path. That is, base/result==path.
50 Path relative(const Path &path, const Path &base);