]> git.tdb.fi Git - libs/core.git/blob - source/utils.h
a828c92e3ed76e21a90efe22b3d7de2c985b7506
[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 struct Filename
17 {
18         std::string base;
19         std::string ext;
20 };
21
22 Path fix_case(const Path &path);
23
24 /// Removes a file
25 void unlink(const Path &path);
26
27 Filename splitext(const std::string &);
28 int fnmatch(const std::string &, const Path &);
29
30 /// Makes a path relative to some base path.  That is, base/result==path.
31 Path relative(const Path &path, const Path &base);
32
33 std::string basename(const std::string &);
34
35 inline bool is_windows_drive(const std::string &p)
36 { return (p.size()==2 && ((p[0]>='A' && p[0]<='Z') || (p[0]>='a' && p[0]<='z')) && p[1]==':'); }
37
38 } // namespace FS
39 } // namespace Msp
40
41 #endif