From 036aae060b91a557157c46c718fe2d1f64808f10 Mon Sep 17 00:00:00 2001 From: expwnent Date: Thu, 19 Jun 2014 22:58:17 -0400 Subject: [PATCH] Merge lethosor stuff. For some reason, git's auto merge message didn't happen because of git-stash shenanigans. Oh well. --- library/include/modules/Filesystem.h | 2 +- library/modules/Filesystem.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/library/include/modules/Filesystem.h b/library/include/modules/Filesystem.h index d40fd910e..3798bbeb2 100644 --- a/library/include/modules/Filesystem.h +++ b/library/include/modules/Filesystem.h @@ -182,7 +182,7 @@ enum _filetype { namespace DFHack { namespace Filesystem { DFHACK_EXPORT bool chdir (std::string path); - DFHACK_EXPORT char * getcwd (); + DFHACK_EXPORT std::string getcwd (); DFHACK_EXPORT bool mkdir (std::string path); DFHACK_EXPORT bool rmdir (std::string path); DFHACK_EXPORT bool stat (std::string path, STAT_STRUCT &info); diff --git a/library/modules/Filesystem.cpp b/library/modules/Filesystem.cpp index 35a48930f..be1668bcc 100644 --- a/library/modules/Filesystem.cpp +++ b/library/modules/Filesystem.cpp @@ -54,18 +54,18 @@ bool DFHack::Filesystem::chdir (std::string path) return !(bool)::chdir(path.c_str()); } -char * DFHack::Filesystem::getcwd () +std::string DFHack::Filesystem::getcwd () { char *path; char buf[LFS_MAXPATHLEN]; + std::string result = ""; #ifdef _WIN32 - if ((path = ::_getcwd(buf, LFS_MAXPATHLEN)) == NULL) + if ((path = ::_getcwd(buf, LFS_MAXPATHLEN)) != NULL) #else - if ((path = ::getcwd(buf, LFS_MAXPATHLEN)) == NULL) + if ((path = ::getcwd(buf, LFS_MAXPATHLEN)) != NULL) #endif - return NULL; - else - return path; + result = buf; + return result; } bool DFHack::Filesystem::mkdir (std::string path)