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.
This commit is contained in:
Aloshi 2013-05-16 12:43:16 -05:00
parent 8803266660
commit 0f6338045a
3 changed files with 32 additions and 10 deletions

8
.gitignore vendored
View file

@ -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
RelWithDebInfo

View file

@ -3,12 +3,12 @@
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<IncludePath>$(IncludePath)</IncludePath>
<LibraryPath>$(LibraryPath)</LibraryPath>
<IncludePath>$(IncludePath)</IncludePath>
<LibraryPath>$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>_DESKTOP_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_DESKTOP_;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>SDLmain.lib;SDL.lib;FreeImage.lib;freetype.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>

View file

@ -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;
}