diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-03-23 21:57:41 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-03-31 21:03:08 +0200 |
commit | 45521d593560b120d406acfb9926697e7ad5e423 (patch) | |
tree | 4d25de9d5aa29a029ac46e3bc6551a32491f8ea8 /src/path.cc | |
parent | d172d756cfcdfbde5c6b8c6d25a51f58624739e6 (diff) |
More cleanup.
Diffstat (limited to 'src/path.cc')
-rw-r--r-- | src/path.cc | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/path.cc b/src/path.cc index 43c64f0..c2e7910 100644 --- a/src/path.cc +++ b/src/path.cc @@ -35,17 +35,19 @@ std::string getPath(const std::string& file) { - std::string p; -#ifndef __MINGW32__ - char *b = strdup(file.c_str()); - p = dirname(b); - free(b); -#else + std::string path; + +#ifdef __MINGW32__ char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; _splitpath(file.c_str(), drive, dir, NULL, NULL); - p = std::string(drive) + dir; + path = std::string(drive) + dir; +#else + // POSIX + char* buffer = strdup(file.c_str()); + path = dirname(buffer); + free(buffer); #endif - return p; + return path; } |