mirror of
https://github.com/gnustep/tools-make.git
synced 2025-04-23 22:33:28 +00:00
Use USERPROFILE for home directory.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/tools/make/trunk@15143 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
bf28fb7049
commit
708352eb20
2 changed files with 31 additions and 16 deletions
|
@ -1,3 +1,7 @@
|
|||
2002-11-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* user_home.c: Use USERPROFILE for home directory on windoze.
|
||||
|
||||
2002-11-19 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Version: 1.5.1
|
||||
|
|
43
user_home.c
43
user_home.c
|
@ -187,28 +187,39 @@ int main (int argc, char** argv)
|
|||
}
|
||||
strncpy(home, pw->pw_dir, sizeof(home));
|
||||
#else
|
||||
/* The environment variable HOMEPATH holds the home directory
|
||||
for the user on Windows NT; Win95 has no concept of home. */
|
||||
len0 = GetEnvironmentVariable("HOMEDRIVE", buf0, 1024);
|
||||
/* The environment variable USERPROFILE holds the home directory
|
||||
for the user on modern versions of windoze. */
|
||||
len0 = GetEnvironmentVariable("USERPROFILE", buf0, 1024);
|
||||
if (len0 > 0 && len0 < 1024)
|
||||
{
|
||||
buf0[len0] = '\0';
|
||||
len1 = GetEnvironmentVariable("HOMEPATH", buf1, 128);
|
||||
if (len1 > 0 && len1 < 128)
|
||||
{
|
||||
buf1[len1] = '\0';
|
||||
sprintf(home, "%s%s", buf0, buf1);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Unable to determine HOMEPATH\n");
|
||||
return 1;
|
||||
}
|
||||
strcpy(home, buf0);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Unable to determine HOMEDRIVE\n");
|
||||
return 1;
|
||||
/* The environment variable HOMEPATH holds the home directory
|
||||
for the user on Windows NT; Win95 has no concept of home. */
|
||||
len0 = GetEnvironmentVariable("HOMEDRIVE", buf0, 1024);
|
||||
if (len0 > 0 && len0 < 1024)
|
||||
{
|
||||
buf0[len0] = '\0';
|
||||
len1 = GetEnvironmentVariable("HOMEPATH", buf1, 128);
|
||||
if (len1 > 0 && len1 < 128)
|
||||
{
|
||||
buf1[len1] = '\0';
|
||||
sprintf(home, "%s%s", buf0, buf1);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Unable to determine HOMEPATH\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Unable to determine HOMEDRIVE\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue