summaryrefslogtreecommitdiff
path: root/src/path.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-03-23 21:57:41 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2016-03-29 22:43:32 +0200
commit6ac5946767ba41d7eff9eb8521519007fdc58750 (patch)
tree3ea70169dfe7568fa97c54c19a6f2de5189ef249 /src/path.cc
parentef1d7e4478649296ccb17900acc949a604097d66 (diff)
More cleanup.
Diffstat (limited to 'src/path.cc')
-rw-r--r--src/path.cc24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/path.cc b/src/path.cc
index 5c899f2..c2e7910 100644
--- a/src/path.cc
+++ b/src/path.cc
@@ -33,19 +33,21 @@
#include <string.h>
#include <stdlib.h>
-std::string getPath(std::string file)
+std::string getPath(const std::string& file)
{
- std::string p;
-#ifndef __MINGW32__
- char *b = strdup(file.c_str());
- p = dirname(b);
- free(b);
+ std::string path;
+
+#ifdef __MINGW32__
+ char drive[_MAX_DRIVE];
+ char dir[_MAX_DIR];
+ _splitpath(file.c_str(), drive, dir, NULL, NULL);
+ path = std::string(drive) + dir;
#else
- char drive[_MAX_DRIVE];
- char dir[_MAX_DIR];
- _splitpath(file.c_str(), drive, dir, NULL, NULL);
- p = std::string(drive) + dir;
+ // POSIX
+ char* buffer = strdup(file.c_str());
+ path = dirname(buffer);
+ free(buffer);
#endif
- return p;
+ return path;
}