From f61a0ec35a5c1db21cf96674e610c9c54d1aa62f Mon Sep 17 00:00:00 2001 From: reksarka Date: Wed, 20 Sep 2023 20:55:59 +0300 Subject: [PATCH] Uses absolute path for destination --- get-sdk.bat | 7 ++++--- utils/destination.bat | 11 ++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/get-sdk.bat b/get-sdk.bat index 55f284c..7fa3500 100644 --- a/get-sdk.bat +++ b/get-sdk.bat @@ -17,13 +17,15 @@ call which check-components >NUL 2>&1 || set "PATH=%~dp0sdk;%PATH%" set url=%~1 call destination "%~2" || exit /b 1 + call check-components "%destination%" && ( echo [WARN][%~n0] SDK already exist! exit /b 0 ) + echo Getting Windows SDK -for %%i in ("%destination%") do set "tmp=%%~fi\tmp" +set "tmp=%destination%\tmp" set "archiver=%tmp%\7-zip" call ensure-archiver "%archiver%" @@ -39,8 +41,7 @@ call get-iso "%url%" "%iso%" || exit /b 2 call extract-installers "%iso%" "%installers%" || exit /b 3 :COMPONENTS -set "lessmsi=%tmp%\lessmsi" -call ensure-lessmsi "%lessmsi%" || exit /b 4 +call ensure-lessmsi "%tmp%\lessmsi" || exit /b 4 set "components=%tmp%\components" call extract-components "%installers%" "%components%" || exit /b 5 call collect-components "%components%" "%destination%" || exit /b 6 diff --git a/utils/destination.bat b/utils/destination.bat index f9bf8eb..383262a 100644 --- a/utils/destination.bat +++ b/utils/destination.bat @@ -1,8 +1,8 @@ @echo off rem -------------------------------------------------------------------------- -rem Sets the %destination% var without trailing backslash and creates the -rem associated dir if needed. +rem Ensures the %destination% is set to an absolute path without trailing +rem backslashes and creates the corresponding dir if necessary. rem -------------------------------------------------------------------------- set destination=%~1 @@ -23,6 +23,11 @@ if "%destination%" == "" ( exit /b 2 ) -if not exist "%destination%" md "%destination%" +for %%i in ("%destination%") do set "destination=%%~fi" + +if not exist "%destination%" md "%destination%" || ( + echo [ERR][%~n0] Unable to create "%destination%"! + exit /b 3 +) exit /b 0