]> git.tdb.fi Git - libs/core.git/blob - source/utils.h
Move is_windows_drive into utils.h
[libs/core.git] / source / utils.h
1 /*
2 This file is part of libmsppath
3 Copyright © 2006  Mikko Rasa, Mikkosoft Productions
4 Distributed under the LGPL
5 */
6 #ifndef MSP_PATH_UTILS_H_
7 #define MSP_PATH_UTILS_H_
8
9 #include <sys/stat.h>
10 #include <unistd.h>
11 #include <list>
12 #include <string>
13 #include "path.h"
14
15 namespace Msp {
16 namespace Path {
17
18 struct Filename
19 {
20         std::string base;
21         std::string ext;
22 };
23
24 extern Path fix_case(const Path &);
25 extern int mkpath(const Path &, int);
26 extern int rmdir(const Path &, bool =false);
27 extern std::list<std::string> list_files(const Path &);
28 extern bool exists(const Path &);
29 extern Filename splitext(const std::string &);
30 extern int fnmatch(const std::string &, const Path &);
31
32 inline int stat(const Path &fn, struct stat &st)
33 { return ::stat(fn.str().c_str(), &st); }
34
35 inline Path getcwd()
36 { char buf[1024]; return ::getcwd(buf, sizeof(buf)); }
37
38 inline bool is_windows_drive(const std::string &p)
39 { return (p.size()==2 && ((p[0]>='A' && p[0]<='Z') || (p[0]>='a' && p[0]<='z')) && p[1]==':'); }
40
41 } // namespace Path
42 } // namespace Msp
43
44 #endif