]> git.tdb.fi Git - libs/core.git/blob - source/utils.h
a6d956869bf633d531d35e24636b8b37519e35f4
[libs/core.git] / source / utils.h
1 /* $Id$
2
3 This file is part of libmspfs
4 Copyright © 2006-2008  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_FS_UTILS_H_
9 #define MSP_FS_UTILS_H_
10
11 namespace Msp {
12 namespace FS {
13
14 class Path;
15
16 /// Extracts the last component of the path.
17 std::string basename(const Path &);
18
19 /// Removes the last component from the path.
20 Path dirname(const Path &);
21
22 /**
23 Returns the base part of a filename.  This includes everything up to the last
24 dot, but not the dot itself.
25 */
26 std::string basepart(const std::string &);
27
28 /**
29 Returns the extension part of a filename.  This includes the last dot and
30 everything after it.
31 */
32 std::string extpart(const std::string &);
33
34 /**
35 Fixes the case of the given path to match files / directories on the
36 filesystem.
37 */
38 Path fix_case(const Path &path);
39
40 /// Removes a file
41 void unlink(const Path &path);
42
43 /// Makes a path relative to some base path.  That is, base/result==path.
44 Path relative(const Path &path, const Path &base);
45
46 } // namespace FS
47 } // namespace Msp
48
49 #endif