aboutsummaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-03-18 19:57:54 +0000
committerRon Yorston <rmy@pobox.com>2018-03-18 19:57:54 +0000
commit411d8b4cf9887c108853a25388837c1aaf31edce (patch)
treebd88371b4720d19fe08209a800c8576d46fa44fd /win32
parent2cbc61ac77a4e661ad97143c3f53db55506d8349 (diff)
downloadbusybox-w32-411d8b4cf9887c108853a25388837c1aaf31edce.tar.gz
busybox-w32-411d8b4cf9887c108853a25388837c1aaf31edce.tar.bz2
busybox-w32-411d8b4cf9887c108853a25388837c1aaf31edce.zip
win32: add a function to convert backslashes to slashes
Diffstat (limited to 'win32')
-rw-r--r--win32/mingw.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/win32/mingw.c b/win32/mingw.c
index ee549c311..112b2a54e 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -665,13 +665,10 @@ struct tm *localtime_r(const time_t *timep, struct tm *result)
665#undef getcwd 665#undef getcwd
666char *mingw_getcwd(char *pointer, int len) 666char *mingw_getcwd(char *pointer, int len)
667{ 667{
668 int i;
669 char *ret = getcwd(pointer, len); 668 char *ret = getcwd(pointer, len);
670 if (!ret) 669 if (!ret)
671 return ret; 670 return ret;
672 for (i = 0; ret[i]; i++) 671 convert_slashes(ret);
673 if (ret[i] == '\\')
674 ret[i] = '/';
675 return ret; 672 return ret;
676} 673}
677 674
@@ -714,7 +711,6 @@ static char *gethomedir(void)
714 static char *buf = NULL; 711 static char *buf = NULL;
715 DWORD len = PATH_MAX; 712 DWORD len = PATH_MAX;
716 HANDLE h; 713 HANDLE h;
717 char *s;
718 714
719 if (!buf) 715 if (!buf)
720 buf = xmalloc(PATH_MAX); 716 buf = xmalloc(PATH_MAX);
@@ -730,11 +726,7 @@ static char *gethomedir(void)
730 726
731 CloseHandle(h); 727 CloseHandle(h);
732 728
733 for ( s=buf; *s; ++s ) { 729 convert_slashes(buf);
734 if ( *s == '\\' ) {
735 *s = '/';
736 }
737 }
738 730
739 return buf; 731 return buf;
740} 732}
@@ -908,8 +900,10 @@ const char *get_busybox_exec_path(void)
908 path[0] = '\0'; 900 path[0] = '\0';
909 } 901 }
910 902
911 if (!*path) 903 if (!*path) {
912 GetModuleFileName(NULL, path, PATH_MAX); 904 GetModuleFileName(NULL, path, PATH_MAX);
905 convert_slashes(path);
906 }
913 return path; 907 return path;
914} 908}
915 909
@@ -1174,6 +1168,15 @@ char *add_win32_extension(const char *p)
1174 return NULL; 1168 return NULL;
1175} 1169}
1176 1170
1171void FAST_FUNC convert_slashes(char *p)
1172{
1173 for (; *p; ++p) {
1174 if ( *p == '\\' ) {
1175 *p = '/';
1176 }
1177 }
1178}
1179
1177#undef opendir 1180#undef opendir
1178DIR *mingw_opendir(const char *path) 1181DIR *mingw_opendir(const char *path)
1179{ 1182{