From 0f6338045ae848145347af60da67b5493b08c42c Mon Sep 17 00:00:00 2001 From: Aloshi Date: Thu, 16 May 2013 12:43:16 -0500 Subject: [PATCH] Added Windows compiled files to .gitignore. Added "WIN32" preprocessor definition to the default VS2010 project. Replaced getHomePath() with the one mentioned in the pull request comments. --- .gitignore | 8 +++++- .../EmulationStation_vs2010/lib_paths.props | 6 ++-- src/platform.cpp | 28 +++++++++++++++---- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 4d087d107..eda1679dc 100644 --- a/.gitignore +++ b/.gitignore @@ -11,11 +11,17 @@ *.la *.a +# And on Windows +*.dll +*.pdb +*.exe.manifest + # Dependency makefiles *.d #Compiled executable emulationstation +emulationstation.exe #build directory EmulationStation_vs2010 @@ -23,4 +29,4 @@ build Debug Release MinSizeRel -RelWithDebInfo \ No newline at end of file +RelWithDebInfo diff --git a/EmulationStation_vs2010/EmulationStation_vs2010/lib_paths.props b/EmulationStation_vs2010/EmulationStation_vs2010/lib_paths.props index 4b9b5bf1d..60ede5e74 100644 --- a/EmulationStation_vs2010/EmulationStation_vs2010/lib_paths.props +++ b/EmulationStation_vs2010/EmulationStation_vs2010/lib_paths.props @@ -3,12 +3,12 @@ - $(IncludePath) - $(LibraryPath) + $(IncludePath) + $(LibraryPath) - _DESKTOP_;%(PreprocessorDefinitions) + _DESKTOP_;WIN32;%(PreprocessorDefinitions) SDLmain.lib;SDL.lib;FreeImage.lib;freetype.lib;opengl32.lib;%(AdditionalDependencies) diff --git a/src/platform.cpp b/src/platform.cpp index bf88d70b2..bb4c5bb14 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -3,10 +3,26 @@ std::string getHomePath() { - //this gives you something like "/home/YOUR_USERNAME" on Linux and "C:\Users\YOUR_USERNAME\" on Windows - const char* home = getenv("HOME"); - if(home == NULL) - return ""; - else - return home; + std::string homePath; + //this should give you something like "/home/YOUR_USERNAME" on Linux and "C:\Users\YOUR_USERNAME\" on Windows + const char * envHome = getenv("HOME"); + if(envHome != nullptr) { + homePath = envHome; + } +#ifdef WIN32 + //but does not seem to work for Windwos XP or Vista, so try something else + if (homePath.empty()) { + const char * envDir = getenv("HOMEDRIVE"); + const char * envPath = getenv("HOMEPATH"); + if (envDir != nullptr && envPath != nullptr) { + homePath = envDir; + homePath += envPath; + } + } +#else + if (homePath.empty()) { + homePath = "~"; + } +#endif + return homePath; }