aboutsummaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-04-23 15:05:26 +0100
committerRon Yorston <rmy@pobox.com>2012-04-23 15:05:26 +0100
commit15e948bdabe8fc69d821a20dfe2bf00b56eb99f3 (patch)
tree34375189e2091646ed6f4d55ab0aad172dc471f2 /win32
parent7543523a11fbc3b8835a334651a3a8084c8a65b7 (diff)
downloadbusybox-w32-15e948bdabe8fc69d821a20dfe2bf00b56eb99f3.tar.gz
busybox-w32-15e948bdabe8fc69d821a20dfe2bf00b56eb99f3.tar.bz2
busybox-w32-15e948bdabe8fc69d821a20dfe2bf00b56eb99f3.zip
win32: support fancy prompts and (limited) tilde expansion
Diffstat (limited to 'win32')
-rw-r--r--win32/mingw.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/win32/mingw.c b/win32/mingw.c
index b99c88444..657d106ed 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -1,4 +1,5 @@
1#include "libbb.h" 1#include "libbb.h"
2#include <userenv.h>
2 3
3unsigned int _CRT_fmode = _O_BINARY; 4unsigned int _CRT_fmode = _O_BINARY;
4 5
@@ -495,6 +496,33 @@ int mingw_rename(const char *pold, const char *pnew)
495 return -1; 496 return -1;
496} 497}
497 498
499static char *gethomedir(void)
500{
501 static char buf[PATH_MAX];
502 DWORD len = sizeof(buf);
503 HANDLE h;
504 char *s;
505
506 buf[0] = '\0';
507 if ( !OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &h) )
508 return buf;
509
510 if ( !GetUserProfileDirectory(h, buf, &len) ) {
511 CloseHandle(h);
512 return buf;
513 }
514
515 CloseHandle(h);
516
517 for ( s=buf; *s; ++s ) {
518 if ( *s == '\\' ) {
519 *s = '/';
520 }
521 }
522
523 return buf;
524}
525
498struct passwd *getpwuid(int uid UNUSED_PARAM) 526struct passwd *getpwuid(int uid UNUSED_PARAM)
499{ 527{
500 static char user_name[100]; 528 static char user_name[100];
@@ -505,7 +533,7 @@ struct passwd *getpwuid(int uid UNUSED_PARAM)
505 return NULL; 533 return NULL;
506 p.pw_name = user_name; 534 p.pw_name = user_name;
507 p.pw_gecos = "unknown"; 535 p.pw_gecos = "unknown";
508 p.pw_dir = NULL; 536 p.pw_dir = gethomedir();
509 return &p; 537 return &p;
510} 538}
511 539