diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-12-28 02:03:53 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-12-28 04:23:48 +0100 |
commit | 7652b3d64a63c587f520633364412345083210d4 (patch) | |
tree | 12d98c301aa931f20aee0875242bc762cf4d22d1 /mmc_updater/src/FileUtils.cpp | |
parent | 30d4f5981d3220386bd320534048594fc364d0e9 (diff) | |
download | MultiMC-7652b3d64a63c587f520633364412345083210d4.tar MultiMC-7652b3d64a63c587f520633364412345083210d4.tar.gz MultiMC-7652b3d64a63c587f520633364412345083210d4.tar.lz MultiMC-7652b3d64a63c587f520633364412345083210d4.tar.xz MultiMC-7652b3d64a63c587f520633364412345083210d4.zip |
Various updater fixes
Updater tests for path utils
The updater now doesn't use splitpath on Windows (fixes problems with Windows XP)
Fix up paths for the OSX updater - should now install the updates into the right place
Fix translations install path - translation isntall and deploy should be fixed
Diffstat (limited to 'mmc_updater/src/FileUtils.cpp')
-rw-r--r-- | mmc_updater/src/FileUtils.cpp | 44 |
1 files changed, 2 insertions, 42 deletions
diff --git a/mmc_updater/src/FileUtils.cpp b/mmc_updater/src/FileUtils.cpp index 10435e49..712c0c5d 100644 --- a/mmc_updater/src/FileUtils.cpp +++ b/mmc_updater/src/FileUtils.cpp @@ -10,6 +10,8 @@ #include <string.h> #include <fstream> #include <iostream> +// this actually works with mingw32, which we use. +#include <libgen.h> #ifdef PLATFORM_UNIX #include <unistd.h> @@ -19,7 +21,6 @@ #include <sys/time.h> #include <sys/stat.h> #include <errno.h> -#include <libgen.h> #endif FileUtils::IOException::IOException(const std::string& error) @@ -249,59 +250,18 @@ void FileUtils::removeFile(const char* src) throw (IOException) std::string FileUtils::fileName(const char* path) { -#ifdef PLATFORM_UNIX char* pathCopy = strdup(path); std::string basename = ::basename(pathCopy); free(pathCopy); return basename; -#else - char baseName[MAX_PATH]; - char extension[MAX_PATH]; - _splitpath_s(path, - 0, /* drive */ - 0, /* drive length */ - 0, /* dir */ - 0, /* dir length */ - baseName, - MAX_PATH, /* baseName length */ - extension, - MAX_PATH /* extension length */ - ); - return std::string(baseName) + std::string(extension); -#endif } std::string FileUtils::dirname(const char* path) { -#ifdef PLATFORM_UNIX char* pathCopy = strdup(path); std::string dirname = ::dirname(pathCopy); free(pathCopy); return dirname; -#else - char drive[3]; - char dir[MAX_PATH]; - - _splitpath_s(path, - drive, /* drive */ - 3, /* drive length */ - dir, - MAX_PATH, /* dir length */ - 0, /* filename */ - 0, /* filename length */ - 0, /* extension */ - 0 /* extension length */ - ); - - std::string result; - if (drive[0]) - { - result += std::string(drive); - } - result += dir; - - return result; -#endif } void FileUtils::touch(const char* path) throw (IOException) |