Fix kiwix-mange problem with relative paths

This commit is contained in:
kelson42 2016-09-04 21:43:26 +02:00
parent 1500cb8329
commit 934a15a0b4
2 changed files with 11 additions and 1 deletions

View File

@ -25,6 +25,8 @@
#elif _WIN32 #elif _WIN32
#include <windows.h> #include <windows.h>
#include "Shlwapi.h" #include "Shlwapi.h"
#include <direct.h>
#define getcwd _getcwd // stupid MSFT "deprecation" warning
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
@ -36,6 +38,7 @@
#define SEPARATOR "\\" #define SEPARATOR "\\"
#else #else
#define SEPARATOR "/" #define SEPARATOR "/"
#include <unistd.h>
#endif #endif
#ifndef PATH_MAX #ifndef PATH_MAX
@ -238,3 +241,10 @@ bool writeTextFile(const string &path, const string &content) {
file.close(); file.close();
return true; return true;
} }
string getCurrentDirectory() {
char* a_cwd = getcwd(NULL,0);
string s_cwd(a_cwd);
free(a_cwd);
return s_cwd;
}

View File

@ -55,6 +55,6 @@ bool makeDirectory(const string &path);
bool copyFile(const string &sourcePath, const string &destPath); bool copyFile(const string &sourcePath, const string &destPath);
string getLastPathElement(const string &path); string getLastPathElement(const string &path);
string getExecutablePath(); string getExecutablePath();
string getCurrentDirectory();
bool writeTextFile(const string &path, const string &content); bool writeTextFile(const string &path, const string &content);
#endif #endif