Merge pull request #1554 from schellap/hostpfiles

Fix program files probe and HOME dir
This commit is contained in:
Senthil 2016-03-18 01:46:37 -07:00
commit 062e538657
2 changed files with 29 additions and 5 deletions

View file

@ -9,6 +9,9 @@
#include <dlfcn.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <pwd.h>
#include <unistd.h>
#include <unistd.h>
@ -112,12 +115,22 @@ bool pal::is_path_rooted(const pal::string_t& path)
bool pal::get_default_packages_directory(pal::string_t* recv)
{
recv->clear();
if (!pal::getenv("HOME", recv))
pal::string_t dir;
if (!pal::getenv("HOME", &dir))
{
struct passwd* pw = getpwuid(getuid());
if (pw && pw->pw_dir)
{
dir.assign(pw->pw_dir);
}
}
if (dir.empty())
{
return false;
}
append_path(&*recv, _X(".nuget"));
append_path(&*recv, _X("packages"));
append_path(&dir, _X(".nuget"));
append_path(&dir, _X("packages"));
recv->assign(dir);
return true;
}

View file

@ -26,7 +26,6 @@ pal::string_t pal::to_string(int value)
bool pal::find_coreclr(pal::string_t* recv)
{
pal::string_t candidate;
pal::string_t test;
// Try %LocalAppData%\dotnet
if (pal::getenv(_X("LocalAppData"), &candidate)) {
@ -39,7 +38,19 @@ bool pal::find_coreclr(pal::string_t* recv)
}
}
// TODO: Try somewhere in Program Files, see https://github.com/dotnet/cli/issues/249
// Try %ProgramFiles%. Note this works for both x86 and x64/wow64 as per:
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa384274(v=vs.85).aspx
// candidate.clear(); getenv clears it.
if (pal::getenv(_X("ProgramFiles"), &candidate)) {
append_path(&candidate, _X("dotnet"));
append_path(&candidate, _X("bin"));
if (coreclr_exists_in_dir(candidate)) {
recv->assign(candidate);
return true;
}
}
return false;
}