]> granicus.if.org Git - php/commitdiff
MFH
authorAndrei Zmievski <andrei@php.net>
Tue, 30 Dec 2008 19:37:35 +0000 (19:37 +0000)
committerAndrei Zmievski <andrei@php.net>
Tue, 30 Dec 2008 19:37:35 +0000 (19:37 +0000)
ext/session/mod_files.bat [new file with mode: 0644]

diff --git a/ext/session/mod_files.bat b/ext/session/mod_files.bat
new file mode 100644 (file)
index 0000000..4ec9a49
--- /dev/null
@@ -0,0 +1,57 @@
+@ECHO OFF\r
+SETLOCAL ENABLEDELAYEDEXPANSION\r
+\r
+IF _%1_==_AUTO_ (\r
+       GOTO MakeDirs\r
+)\r
+\r
+IF _%2_==__ (\r
+       ECHO Usage %0 ^<basedir^> ^<depth^> ^[^hash_bits^]\r
+       ECHO.\r
+       ECHO Where ^<basedir^>   is the session directory \r
+       ECHO       ^<depth^>     is the number of levels defined in session.save_path\r
+       ECHO       ^[hash_bits^] is the number of bits defined in session.hash_bits_per_character\r
+       EXIT /B 1\r
+)\r
+\r
+SET /A Depth=%2 + 0 2>NUL\r
+IF /I %ERRORLEVEL% EQU 9167 GOTO DepthError\r
+IF _%Depth%_==__ GOTO DepthError\r
+IF /I %Depth% LEQ 0 GOTO DepthError\r
+\r
+IF _%3_==__ GOTO DefaultBits\r
+\r
+SET /A Bits=%3 + 0 2>NUL\r
+IF /I %ERRORLEVEL% EQU 9167 GOTO BitsError\r
+IF _%Bits%_==__ GOTO BitsError\r
+IF /I %Bits% LSS 4 GOTO BitsError\r
+IF /I %Bits% GTR 6 GOTO BitsError\r
+GOTO BitsSet\r
+\r
+:DefaultBits\r
+SET Bits=4\r
+:BitsSet\r
+\r
+SET HashChars=0 1 2 3 4 5 6 7 8 9 A B C D E F\r
+IF /I %Bits% GEQ 5 SET HashChars=!HashChars! G H I J K L M N O P Q R S T U V\r
+IF /I %Bits% GEQ 6 SET HashChars=!HashChars! W X Y Z  - ,\r
+\r
+FOR %%A IN (%HashChars%) DO (\r
+       ECHO Making %%A\r
+       CALL "%~0" AUTO "%~1\%%~A" %Depth%\r
+)\r
+GOTO :EOF\r
+\r
+:MakeDirs\r
+MKDIR "%~2"\r
+SET /A ThisDepth=%3 - 1\r
+IF /I %ThisDepth% GTR 0 FOR %%A IN (%HashChars%) DO CALL "%~0" AUTO "%~2\%%~A" %ThisDepth%\r
+GOTO :EOF\r
+\r
+:DepthError\r
+ECHO ERROR: Invalid depth : %2\r
+EXIT /B 0\r
+\r
+:BitsError\r
+ECHO ERROR: Invalid hash_bits : %3\r
+EXIT /B 0\r