Add GetWorkingDirectory for linux

This commit is contained in:
Jacob Dufault 2017-10-24 19:11:11 -07:00
parent ccff74a79c
commit 37ab94e7b4

View File

@ -147,6 +147,16 @@ std::unique_ptr<PlatformSharedMemory> CreatePlatformSharedMemory(
void PlatformInit() {} void PlatformInit() {}
std::string GetWorkingDirectory() {
char result[FILENAME_MAX];
if (!getcwd(result, sizeof(result)))
return "";
std::string working_dir = std::string(result, strlen(result));
EnsureEndsInSlash(working_dir);
return working_dir;
}
std::string NormalizePath(const std::string& path) { std::string NormalizePath(const std::string& path) {
errno = 0; errno = 0;
char name[PATH_MAX + 1]; char name[PATH_MAX + 1];