3 This file is part of libmspfs
4 Copyright © 2006-2008 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
9 #include <msp/core/except.h>
13 #include <msp/strings/glob.h>
15 #include <msp/strings/utils.h>
25 string basename(const Path &p)
30 Path dirname(const Path &p)
32 return p.subpath(0, p.size()-1);
35 string basepart(const string &fn)
37 unsigned dot=fn.rfind('.');
38 return fn.substr(0, dot);
41 string extpart(const string &fn)
43 unsigned dot=fn.rfind('.');
46 return fn.substr(dot);
49 Path fix_case(const Path &path)
53 for(Path::Iterator i=path.begin(); i!=path.end(); ++i)
61 files=list_files(result);
63 files=list_files(".");
66 for(list<string>::iterator j=files.begin(); (j!=files.end() && !found); ++j)
67 if(!strcasecmp(*j,*i))
81 void unlink(const Path &path)
83 if(::unlink(path.str().c_str())==-1)
84 throw SystemError("unlink failed", errno);
87 Path relative(const Path &path, const Path &base)
89 Path::Iterator i=path.begin();
90 Path::Iterator j=base.begin();
91 for(; (i!=path.end() && j!=base.end() && *i==*j); ++i, ++j) ;
94 for(; j!=base.end(); ++j)
96 for(; i!=path.end(); ++i)