From 8ad159609280c1ef50e741ac44ccf5300f09b6bc Mon Sep 17 00:00:00 2001 From: Sebastian Thomschke Date: Wed, 4 Oct 2017 16:05:00 +0200 Subject: Fix detection of directories on Windows Function tools.delete performs a test to determine if a path is a file or a directory to select the appropriate delete command rmdir vs del. The current test however results in rmdir being used on files too, which then results in a build abortion with error "The directory name is invalid.". E.g. if exist "c:\luarocks\share\lua\5.2\luasocket_3_0rc1_2-socket.lua\" ( echo "I am a folder" ) else ( echo "I am a file" ) wrongly prints "I am a folder" (tested on Windows 10) Whereas if exist "c:\luarocks\share\lua\5.2\luasocket_3_0rc1_2-socket.lua\*" ( echo "I am a folder" ) else ( echo "I am a file" ) correctly prints "I am a file" (tested on Windows 10) This fixes #670 (Also see https://stackoverflow.com/a/1466528/1793220 ) --- src/luarocks/fs/win32/tools.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua index 4adc78d1..6016bc1f 100644 --- a/src/luarocks/fs/win32/tools.lua +++ b/src/luarocks/fs/win32/tools.lua @@ -93,7 +93,7 @@ end function tools.delete(arg) assert(arg) assert(arg:match("^[a-zA-Z]?:?[\\/]")) - fs.execute_quiet("if exist "..fs.Q(arg.."\\").." ( RMDIR /S /Q "..fs.Q(arg).." ) else ( DEL /Q /F "..fs.Q(arg).." )") + fs.execute_quiet("if exist "..fs.Q(arg.."\\*").." ( RMDIR /S /Q "..fs.Q(arg).." ) else ( DEL /Q /F "..fs.Q(arg).." )") end --- Recursively scan the contents of a directory. -- cgit v1.2.3-55-g6feb