Don't require mspmisc
authorMikko Rasa <tdb@tdb.fi>
Fri, 25 May 2007 17:33:34 +0000 (17:33 +0000)
committerMikko Rasa <tdb@tdb.fi>
Fri, 25 May 2007 17:33:34 +0000 (17:33 +0000)
Use globcasematch from mspstrings to implement fnmatch on win32
Fix some style errors

Build
source/Module [deleted file]
source/path.h
source/utils.cpp

diff --git a/Build b/Build
index 43bd137c1081202d9270183460e0d00887429065..658679200591aa63b26ccfe2af058afb9fc253c4 100644 (file)
--- a/Build
+++ b/Build
@@ -3,7 +3,6 @@ package "msppath"
        version "0.1";
        description "Filesystem utilities";
 
-       require "mspmisc";
        require "mspstrings";
 
        library "msppath"
diff --git a/source/Module b/source/Module
deleted file mode 100644 (file)
index 39500d1..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-type="library"
-target="msppath"
-installheaders="path"
-installtarget=1
index 0f333018fc2bdbb1de6d7f89182f6ded2ea8a606..6662a8c20a875856c347d6488747f9c515ecdb5f 100644 (file)
@@ -48,7 +48,7 @@ public:
        unsigned    size() const;
        bool        empty() const { return path.empty(); }
        bool        is_absolute() const;
-       Path        subpath(unsigned, unsigned =(unsigned)-1) const;
+       Path        subpath(unsigned, unsigned =static_cast<unsigned>(-1)) const;
        Path        operator/(const Path &p) const { Path a=*this; a/=p; return a; }
        Path        &operator/=(const Path &);
        std::string operator[](int) const;
index 5c7d6a230803bcaf47c08b9e43b21aaeb2e55ae6..6c48d62a5eecfbafe855cf70b07fb4f2cf553f0b 100644 (file)
@@ -8,6 +8,8 @@ Distributed under the LGPL
 #include <errno.h>
 #ifndef WIN32
 #include <fnmatch.h>
+#else
+#include <msp/strings/glob.h>
 #endif
 #include <msp/strings/utils.h>
 #include "path.h"
@@ -89,6 +91,7 @@ int mkpath(const Path &path, int mode)
                {
 #ifdef WIN32
                        // The win32 version of this function doesn't take the mode argument.  Go figure.
+                       (void)mode;
                        err=mkdir(p.str().c_str());
 #else
                        err=mkdir(p.str().c_str(),mode);
@@ -133,7 +136,8 @@ list<string> list_files(const Path &path)
                while(dirent *de=readdir(dir))
                {
                        const char *fn=de->d_name;
-                       if(fn[0]=='.' && (fn[1]==0 || (fn[1]=='.' && fn[2]==0))) continue;
+                       if(fn[0]=='.' && (fn[1]==0 || (fn[1]=='.' && fn[2]==0))) 
+                               continue;
                        result.push_back(fn);
                }
                closedir(dir);
@@ -144,14 +148,14 @@ list<string> list_files(const Path &path)
 bool exists(const Path &path)
 {
        struct stat st;
-       return !stat(path.str().c_str(),&st);
+       return !stat(path.str().c_str(), &st);
 }
 
 Filename splitext(const string &fn)
 {
        Filename result;
        unsigned dot=fn.rfind('.');
-       result.base=fn.substr(0,dot);
+       result.base=fn.substr(0, dot);
        if(dot!=string::npos)
                result.ext=fn.substr(dot);
        return result;
@@ -160,7 +164,7 @@ Filename splitext(const string &fn)
 int fnmatch(const string &pat, const Path &fn)
 {
 #ifdef WIN32
-       return -1;
+       return globcasematch(pat, fn);
 #else
        return ::fnmatch(pat.c_str(), fn.str().c_str(), FNM_PATHNAME);
 #endif