From: Gurusamy Sarathy Date: Mon, 20 Dec 1999 17:18:23 +0000 (+0000) Subject: virtual directory handling broken on paths with trailing slash X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fd9459bc435247011bdd5dc44ff2358cc4d1b124;p=p5sagit%2Fp5-mst-13.2.git virtual directory handling broken on paths with trailing slash p4raw-id: //depot/perl@4702 --- diff --git a/win32/Makefile b/win32/Makefile index b193ab1..301b804 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -173,7 +173,7 @@ EXTRALIBDIRS = # set this to your email address (perl will guess a value from # from your loginname and your hostname, which may not be right) # -#EMAIL = +#EMAIL = ## ## Build configuration ends. @@ -291,6 +291,7 @@ INST_HTML = $(INST_POD)\html CC = cl LINK32 = link LIB32 = $(LINK32) -lib +RSC = rc # # Options @@ -318,6 +319,9 @@ PERLCRTLIBC = PerlCRT.lib ! ENDIF !ENDIF +PERLEXE_RES = +PERLDLL_RES = + !IF "$(RUNTIME)" == "-MD" LIBC = $(PERLCRTLIBC) !ELSE @@ -375,7 +379,7 @@ o = .obj # Rules # -.SUFFIXES : .c $(o) .dll .lib .exe +.SUFFIXES : .c $(o) .dll .lib .exe .rc .res .c$(o): $(CC) -c -I$( perldll.def -$(PERLDLL): perldll.def $(PERLDLL_OBJ) +$(PERLDLL): perldll.def $(PERLDLL_OBJ) $(PERLDLL_RES) $(LINK32) -dll -def:perldll.def -out:$@ @<< - $(LINK_FLAGS) $(LIBFILES) $(PERLDLL_OBJ) + $(LINK_FLAGS) $(LIBFILES) $(PERLDLL_OBJ) $(PERLDLL_RES) << $(XCOPY) $(PERLIMPLIB) $(COREDIR) @@ -822,9 +829,9 @@ perlmain.c : runperl.c perlmain$(o) : perlmain.c $(CC) $(CFLAGS_O) -UPERLDLL $(OBJOUT_FLAG)$@ -c perlmain.c -$(PERLEXE): $(PERLDLL) $(CONFIGPM) $(PERLEXE_OBJ) +$(PERLEXE): $(PERLDLL) $(CONFIGPM) $(PERLEXE_OBJ) $(PERLEXE_RES) $(LINK32) -subsystem:console -out:$@ $(LINK_FLAGS) $(LIBFILES) \ - $(PERLEXE_OBJ) $(SETARGV_OBJ) $(PERLIMPLIB) + $(PERLEXE_OBJ) $(SETARGV_OBJ) $(PERLIMPLIB) $(PERLEXE_RES) copy $(PERLEXE) $(WPERLEXE) editbin /subsystem:windows $(WPERLEXE) copy splittree.pl .. diff --git a/win32/makefile.mk b/win32/makefile.mk index 592588a..3b64395 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -159,7 +159,7 @@ CCTYPE *= BORLAND # so you may have to set CCHOME explicitly (spaces in the path name should # not be quoted) # -CCHOME *= d:\bc5 +CCHOME *= c:\bc5 #CCHOME *= $(MSVCDIR) #CCHOME *= D:\packages\mingw32 CCINCDIR *= $(CCHOME)\include @@ -302,6 +302,7 @@ CC = bcc32 LINK32 = tlink32 LIB32 = tlib /P128 IMPLIB = implib -c +RSC = rc # # Options @@ -338,6 +339,7 @@ CC = gcc LINK32 = gcc LIB32 = ar rc IMPLIB = dlltool +RSC = rc o = .o a = .a @@ -393,6 +395,7 @@ PRIV_LINK_FLAGS = -L"$(COREDIR)" CC = cl LINK32 = link LIB32 = $(LINK32) -lib +RSC = rc # # Options @@ -420,6 +423,9 @@ PERLCRTLIBC = PerlCRT.lib .ENDIF .ENDIF +PERLEXE_RES = +PERLDLL_RES = + .IF "$(RUNTIME)" == "-MD" LIBC = $(PERLCRTLIBC) .ELSE @@ -495,7 +501,7 @@ LKPOST = ) # Rules # -.SUFFIXES : .c $(o) .dll $(a) .exe +.SUFFIXES : .c $(o) .dll $(a) .exe .rc .res .c$(o): $(CC) -c $(null,$(<:d) $(NULL) -I$(<:d)) $(CFLAGS_O) $(OBJOUT_FLAG)$@ $< @@ -515,6 +521,9 @@ $(o).dll: -out:$@ $(BLINK_FLAGS) $(LIBFILES) $< $(LIBPERL) .ENDIF +.rc.res: + $(RSC) $< + # # various targets MINIPERL = ..\miniperl.exe @@ -1040,7 +1049,7 @@ perldll.def : $(MINIPERL) $(CONFIGPM) ..\global.sym ..\pp.sym ..\makedef.pl $(MINIPERL) -w ..\makedef.pl PLATFORM=win32 $(OPTIMIZE) $(DEFINES) \ $(BUILDOPT) CCTYPE=$(CCTYPE) > perldll.def -$(PERLDLL): perldll.def $(PERLDLL_OBJ) +$(PERLDLL): perldll.def $(PERLDLL_OBJ) $(PERLDLL_RES) .IF "$(CCTYPE)" == "BORLAND" $(LINK32) -Tpd -ap $(BLINK_FLAGS) \ @$(mktmp c0d32$(o) $(PERLDLL_OBJ:s,\,\\)\n \ @@ -1061,7 +1070,7 @@ $(PERLDLL): perldll.def $(PERLDLL_OBJ) perl.exp $(LKPOST)) .ELSE $(LINK32) -dll -def:perldll.def -out:$@ \ - @$(mktmp $(BLINK_FLAGS) $(LIBFILES) $(PERLDLL_OBJ:s,\,\\)) + @$(mktmp $(BLINK_FLAGS) $(LIBFILES) $(PERLDLL_RES) $(PERLDLL_OBJ:s,\,\\)) .ENDIF $(XCOPY) $(PERLIMPLIB) $(COREDIR) @@ -1103,7 +1112,7 @@ perlmain.c : runperl.c perlmain$(o) : perlmain.c $(CC) $(CFLAGS_O) -UPERLDLL $(OBJOUT_FLAG)$@ -c perlmain.c -$(PERLEXE): $(PERLDLL) $(CONFIGPM) $(PERLEXE_OBJ) +$(PERLEXE): $(PERLDLL) $(CONFIGPM) $(PERLEXE_OBJ) $(PERLEXE_RES) .IF "$(CCTYPE)" == "BORLAND" $(LINK32) -Tpe -ap $(BLINK_FLAGS) \ @$(mktmp c0x32$(o) $(PERLEXE_OBJ:s,\,\\)\n \ @@ -1114,7 +1123,7 @@ $(PERLEXE): $(PERLDLL) $(CONFIGPM) $(PERLEXE_OBJ) $(PERLEXE_OBJ) $(PERLIMPLIB) $(LIBFILES) .ELSE $(LINK32) -subsystem:console -out:$@ $(BLINK_FLAGS) $(LIBFILES) \ - $(PERLEXE_OBJ) $(SETARGV_OBJ) $(PERLIMPLIB) + $(PERLEXE_OBJ) $(SETARGV_OBJ) $(PERLIMPLIB) $(PERLEXE_RES) copy $(PERLEXE) $(WPERLEXE) editbin /subsystem:windows $(WPERLEXE) .ENDIF diff --git a/win32/vdir.h b/win32/vdir.h index 0d21616..a8a34e4 100644 --- a/win32/vdir.h +++ b/win32/vdir.h @@ -321,32 +321,27 @@ int VDir::SetCurrentDirectoryA(char *lpBuffer) HANDLE hHandle; WIN32_FIND_DATA win32FD; char szBuffer[MAX_PATH+1], *pPtr; - int nRet = -1; + int length, nRet = -1; GetFullPathNameA(MapPathA(lpBuffer), sizeof(szBuffer), szBuffer, &pPtr); + /* if the last char is a '\\' or a '/' then add + * an '*' before calling FindFirstFile + */ + length = strlen(szBuffer); + if(length > 0 && IsPathSep(szBuffer[length-1])) { + szBuffer[length] = '*'; + szBuffer[length+1] = '\0'; + } - hHandle = FindFirstFile(szBuffer, &win32FD); + hHandle = FindFirstFileA(szBuffer, &win32FD); if (hHandle != INVALID_HANDLE_VALUE) { FindClose(hHandle); - SetDefaultDirA(szBuffer, DriveIndex(szBuffer[0])); - nRet = 0; - } - return nRet; -} - -int VDir::SetCurrentDirectoryW(WCHAR *lpBuffer) -{ - HANDLE hHandle; - WIN32_FIND_DATAW win32FD; - WCHAR szBuffer[MAX_PATH+1], *pPtr; - int nRet = -1; - GetFullPathNameW(MapPathW(lpBuffer), (sizeof(szBuffer)/sizeof(WCHAR)), szBuffer, &pPtr); + /* if an '*' was added remove it */ + if(szBuffer[length] == '*') + szBuffer[length] = '\0'; - hHandle = FindFirstFileW(szBuffer, &win32FD); - if (hHandle != INVALID_HANDLE_VALUE) { - FindClose(hHandle); - SetDefaultDirW(szBuffer, DriveIndex((char)szBuffer[0])); + SetDefaultDirA(szBuffer, DriveIndex(szBuffer[0])); nRet = 0; } return nRet; @@ -463,5 +458,35 @@ WCHAR* VDir::MapPathW(const WCHAR *pInName) return szLocalBufferW; } +int VDir::SetCurrentDirectoryW(WCHAR *lpBuffer) +{ + HANDLE hHandle; + WIN32_FIND_DATAW win32FD; + WCHAR szBuffer[MAX_PATH+1], *pPtr; + int length, nRet = -1; + + GetFullPathNameW(MapPathW(lpBuffer), (sizeof(szBuffer)/sizeof(WCHAR)), szBuffer, &pPtr); + /* if the last char is a '\\' or a '/' then add + * an '*' before calling FindFirstFile + */ + length = wcslen(szBuffer); + if(length > 0 && IsPathSep(szBuffer[length-1])) { + szBuffer[length] = '*'; + szBuffer[length+1] = '\0'; + } + + hHandle = FindFirstFileW(szBuffer, &win32FD); + if (hHandle != INVALID_HANDLE_VALUE) { + FindClose(hHandle); + + /* if an '*' was added remove it */ + if(szBuffer[length] == '*') + szBuffer[length] = '\0'; + + SetDefaultDirW(szBuffer, DriveIndex((char)szBuffer[0])); + nRet = 0; + } + return nRet; +} #endif /* ___VDir_H___ */