aboutsummaryrefslogtreecommitdiff
path: root/mmc_updater/src/FileUtils.cpp
diff options
context:
space:
mode:
authorForkk <forkk@forkk.net>2014-01-02 13:38:20 -0600
committerForkk <forkk@forkk.net>2014-01-02 13:38:20 -0600
commit17f1864a71b69b9df14d8e06ed48a65e678d09c9 (patch)
tree4d98a2b3493a26017150d6ba8c5ae0419de3de7d /mmc_updater/src/FileUtils.cpp
parent4495e20cd7f7f2ab062f3b60f19ac4b79f32c350 (diff)
parentaa5f2c8120cc23de0d57c9f0280512adb9a531b3 (diff)
downloadPrismLauncher-17f1864a71b69b9df14d8e06ed48a65e678d09c9.tar.gz
PrismLauncher-17f1864a71b69b9df14d8e06ed48a65e678d09c9.tar.bz2
PrismLauncher-17f1864a71b69b9df14d8e06ed48a65e678d09c9.zip
Merge branch 'develop' of github.com:MultiMC/MultiMC5 into feature_news
Conflicts: CMakeLists.txt gui/MainWindow.h
Diffstat (limited to 'mmc_updater/src/FileUtils.cpp')
-rw-r--r--mmc_updater/src/FileUtils.cpp44
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)