]> git.tdb.fi Git - libs/core.git/blobdiff - source/utils.cpp
Don't require mspmisc
[libs/core.git] / source / utils.cpp
index 5c7d6a230803bcaf47c08b9e43b21aaeb2e55ae6..6c48d62a5eecfbafe855cf70b07fb4f2cf553f0b 100644 (file)
@@ -8,6 +8,8 @@ Distributed under the LGPL
 #include <errno.h>
 #ifndef WIN32
 #include <fnmatch.h>
 #include <errno.h>
 #ifndef WIN32
 #include <fnmatch.h>
+#else
+#include <msp/strings/glob.h>
 #endif
 #include <msp/strings/utils.h>
 #include "path.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.
                {
 #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);
                        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;
                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);
                        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;
 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('.');
 }
 
 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;
        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
 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
 #else
        return ::fnmatch(pat.c_str(), fn.str().c_str(), FNM_PATHNAME);
 #endif