diff --git a/stepmania/PBProject/Installer/Helper.mm b/stepmania/PBProject/Installer/Helper.mm index 96bf1ab406..c2b1b6a6a7 100644 --- a/stepmania/PBProject/Installer/Helper.mm +++ b/stepmania/PBProject/Installer/Helper.mm @@ -30,6 +30,8 @@ void HandleFile(const CString& file, const CString& dir, const CString& archiveP NSString *filePath = [NSString stringWithCString:dir]; filePath = [filePath stringByAppendingFormat:@"%s%s", (dir == "/" ? "" : "/"), file.c_str()]; + if (!overwrite && DoesFileExist([filePath cString])) + return; [c postMessage:filePath]; /* This is rediculus */ char f[file.length() + 1]; @@ -60,7 +62,7 @@ void HandleFile(const CString& file, const CString& dir, const CString& archiveP status = AuthorizationExecuteWithPrivileges(auth, path, kAuthorizationFlagDefaults, arguments+1, NULL); if (status != errAuthorizationSuccess) [c postMessage:@"failed"]; - wait(&status); + wait(&int(status)); } else { diff --git a/stepmania/PBProject/Installer/Util.cpp b/stepmania/PBProject/Installer/Util.cpp index e21921b32b..93d73fdd01 100644 --- a/stepmania/PBProject/Installer/Util.cpp +++ b/stepmania/PBProject/Installer/Util.cpp @@ -38,6 +38,12 @@ inline bool IsADirectory(const CString& path) return s.st_mode & S_IFDIR; } +bool DoesFileExist(const CString& path) +{ + struct stat s; + return !stat(path, &s); +} + inline CString LastPathComponent(const CString& path) { unsigned pos = path.rfind('/'); diff --git a/stepmania/PBProject/Installer/Util.h b/stepmania/PBProject/Installer/Util.h index 0acc7f00b3..954d5b97e2 100644 --- a/stepmania/PBProject/Installer/Util.h +++ b/stepmania/PBProject/Installer/Util.h @@ -14,7 +14,8 @@ using namespace std; void split(const CString& Source, const CString& Deliminator, vector& AddIt); bool IsADirectory(const CString& path); -CString LastPathComponent(const CString& path); +bool DoesFileExist(const CString& path); +inline CString LastPathComponent(const CString& path); void FileListingForDirectoryWithIgnore(const CString& path, CStringArray& list, CStringArray& dirs, const set& ignore, bool ignoreDot = true); int mkdir_p(const CString& path);