From 05ea50ffd15fa74ab1059df2c63442fdf83dec96 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 25 May 2007 17:33:34 +0000 Subject: [PATCH] Don't require mspmisc Use globcasematch from mspstrings to implement fnmatch on win32 Fix some style errors --- Build | 1 - source/Module | 4 ---- source/path.h | 2 +- source/utils.cpp | 12 ++++++++---- 4 files changed, 9 insertions(+), 10 deletions(-) delete mode 100644 source/Module diff --git a/Build b/Build index 43bd137..6586792 100644 --- 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 index 39500d1..0000000 --- a/source/Module +++ /dev/null @@ -1,4 +0,0 @@ -type="library" -target="msppath" -installheaders="path" -installtarget=1 diff --git a/source/path.h b/source/path.h index 0f33301..6662a8c 100644 --- a/source/path.h +++ b/source/path.h @@ -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(-1)) const; Path operator/(const Path &p) const { Path a=*this; a/=p; return a; } Path &operator/=(const Path &); std::string operator[](int) const; diff --git a/source/utils.cpp b/source/utils.cpp index 5c7d6a2..6c48d62 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -8,6 +8,8 @@ Distributed under the LGPL #include #ifndef WIN32 #include +#else +#include #endif #include #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 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 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 -- 2.43.0