+if %errorlevel% neq 0 goto :fail\r
+\r
+call :msg "hidden system file"\r
+echo 1 > file\r
+attrib +h +s file\r
+call :do_test\r
+if %errorlevel% neq 0 goto :fail\r
+\r
+call :msg "hidden, readonly, system file"\r
+echo 1 > file\r
+attrib +h +r +s file\r
+call :do_test\r
+if %errorlevel% neq 0 goto :fail\r
+\r
+call :msg "hidden directory"\r
+md subdir\r
+attrib +h subdir\r
+call :do_test\r
+if %errorlevel% neq 0 goto :fail\r
+\r
+call :msg "hidden system directory"\r
+md subdir\r
+attrib +h +s subdir\r
+call :do_test\r
+if %errorlevel% neq 0 goto :fail\r
+\r
+call :msg "hidden, readonly, system directory"\r
+md subdir\r
+attrib +h +r +s subdir\r
+call :do_test\r
+if %errorlevel% neq 0 goto :fail\r
+\r
+call :msg "readonly directory with named data stream"\r
+md subdir\r
+echo foo > subdir:ads\r
+attrib +r subdir\r
+call :do_test\r
+if %errorlevel% neq 0 goto :fail\r
+\r
+call :msg "encrypted file"\r
+echo "hello" > encrypted\r
+cipher /e encrypted > nul\r
+call :do_test\r
+if %errorlevel% neq 0 goto :fail\r
+\r
+call :msg "identical encrypted files"\r
+echo "hello" > encrypted1\r
+echo "hello" > encrypted2\r
+cipher /e encrypted1 > nul\r
+cipher /e encrypted2 > nul\r
+call :do_test\r
+if %errorlevel% neq 0 goto :fail\r
+\r
+call :msg "encrypted directory"\r
+md subdir\r
+cipher /e subdir > nul\r
+call :do_test\r
+if %errorlevel% neq 0 goto :fail\r
+\r
+call :msg "encrypted directory with encrypted file in it"\r
+md subdir\r
+echo 1 > subdir\1\r
+cipher /e subdir > nul\r
+cipher /e subdir\1 > nul\r
+call :do_test\r
+if %errorlevel% neq 0 goto :fail\r
+\r
+call :msg "encrypted directory with unencrypted file in it"\r
+md subdir\r
+echo 1 > subdir\1\r
+cipher /e subdir > nul\r
+cipher /d subdir\1 > nul\r
+call :do_test\r
+if %errorlevel% neq 0 goto :fail\r
+\r
+call :msg "encrypted root directory"\r
+cd ..\r
+cipher /e in.dir > nul\r
+cd in.dir\r
+echo "hello" > encrypted\r
+call :do_test\r
+if %errorlevel% neq 0 goto :fail\r
+\r
+call :msg "unencrypted file in encrypted directory in compressed directory"\r
+md 1\r
+md 1\2\r
+compact /c 1 > nul\r
+cipher /e 1\2 > nul\r
+echo hello > 1\2\file\r
+cipher /d 1\2\file > nul\r
+call :do_test\r
+if %errorlevel% neq 0 goto :fail\r
+\r
+call :msg "encrypted directory with alternate data streams"\r
+md subdir\r
+cipher /e subdir > nul\r
+echo ads1 > subdir:ads1\r
+echo ads2 > subdir:ads2\r
+call :do_test\r
+if %errorlevel% neq 0 goto :fail\r
+\r
+call :msg "hardlinked, encrypted file with alternate data streams"\r
+echo hello > file\r
+echo hello > file:ads\r
+cipher /e file > nul\r
+mklink /h link file > nul\r
+call :do_test\r
+if %errorlevel% neq 0 goto :fail\r
+\r
+:rpfix_tests\r
+\r
+echo Testing rpfix junction\r
+md subdir\r
+echo 1 > subdir\file\r
+mklink /j junction subdir > nul\r
+cd ..\r
+%WIMLIB_IMAGEX% capture in.dir test.wim > nul\r
+rd /s /q in.dir\r
+%WIMLIB_IMAGEX% apply test.wim out.dir > nul\r
+echo 1 > tmp1\r
+type out.dir\junction\file > tmp2\r
+fc tmp1 tmp2 > nul\r
+if %errorlevel% neq 0 goto :fail\r
+rd /s /q out.dir\r
+del tmp1 tmp2\r
+md in.dir\r
+cd in.dir\r
+\r
+echo Testing rpfix relative\r
+echo 1 > file\r
+mklink relink file > nul\r
+cd ..\r
+%WIMLIB_IMAGEX% capture in.dir test.wim > nul\r
+%WIMLIB_IMAGEX% apply test.wim out.dir > nul\r
+type out.dir\relink > out.dir\tmp\r
+if %errorlevel% neq 0 goto :fail\r
+fc in.dir\file out.dir\tmp > nul\r
+if %errorlevel% neq 0 goto :fail\r
+rd /s /q in.dir out.dir\r
+md in.dir\r
+cd in.dir\r