From c67bbf3922918b579b87b36fac3f41ec09958db6 Mon Sep 17 00:00:00 2001 From: kelson42 Date: Mon, 6 May 2013 21:26:31 +0200 Subject: [PATCH] + fix for MSVC2010 --- src/common/pathTools.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/common/pathTools.cpp b/src/common/pathTools.cpp index 35a18f33..b736ee55 100644 --- a/src/common/pathTools.cpp +++ b/src/common/pathTools.cpp @@ -55,12 +55,23 @@ string computeAbsolutePath(const string path, const string relativePath) { if (path.empty()) { char *path=NULL; size_t size = 0; + +#ifdef _WIN32 + path = _getcwd(path,size); +#else path = getcwd(path,size); +#endif + absolutePath = string(path) + separator; } else { absolutePath = path[path.length() - 1] == separator[0] ? path : path + separator; } + +#if _WIN32 + char *cRelativePath = _strdup(relativePath.c_str()); +#else char *cRelativePath = strdup(relativePath.c_str()); +#endif char *token = strtok(cRelativePath, "/"); while (token != NULL) { @@ -119,8 +130,14 @@ string getLastPathElement(const string &path) { } unsigned int getFileSize(const string &path) { +#ifdef _WIN32 + struct _stat filestatus; + _stat(path.c_str(), &filestatus); +#else struct stat filestatus; stat(path.c_str(), &filestatus); +#endif + return filestatus.st_size / 1024; }