xref: /PHP-5.3/ext/session/mod_files.bat (revision cae97c3b)
1@ECHO OFF
2SETLOCAL ENABLEDELAYEDEXPANSION
3
4IF _%1_==_AUTO_ (
5	GOTO MakeDirs
6)
7
8IF _%2_==__ (
9	ECHO Usage %0 ^<basedir^> ^<depth^> ^[^hash_bits^]
10	ECHO.
11	ECHO Where ^<basedir^>   is the session directory
12	ECHO       ^<depth^>     is the number of levels defined in session.save_path
13	ECHO       ^[hash_bits^] is the number of bits defined in session.hash_bits_per_character
14	EXIT /B 1
15)
16
17SET /A Depth=%2 + 0 2>NUL
18IF /I %ERRORLEVEL% EQU 9167 GOTO DepthError
19IF _%Depth%_==__ GOTO DepthError
20IF /I %Depth% LEQ 0 GOTO DepthError
21
22IF _%3_==__ GOTO DefaultBits
23
24SET /A Bits=%3 + 0 2>NUL
25IF /I %ERRORLEVEL% EQU 9167 GOTO BitsError
26IF _%Bits%_==__ GOTO BitsError
27IF /I %Bits% LSS 4 GOTO BitsError
28IF /I %Bits% GTR 6 GOTO BitsError
29GOTO BitsSet
30
31:DefaultBits
32SET Bits=4
33:BitsSet
34
35SET HashChars=0 1 2 3 4 5 6 7 8 9 A B C D E F
36IF /I %Bits% GEQ 5 SET HashChars=!HashChars! G H I J K L M N O P Q R S T U V
37IF /I %Bits% GEQ 6 SET HashChars=!HashChars! W X Y Z  - ,
38
39FOR %%A IN (%HashChars%) DO (
40	ECHO Making %%A
41	CALL "%~0" AUTO "%~1\%%~A" %Depth%
42)
43GOTO :EOF
44
45:MakeDirs
46MKDIR "%~2"
47SET /A ThisDepth=%3 - 1
48IF /I %ThisDepth% GTR 0 FOR %%A IN (%HashChars%) DO CALL "%~0" AUTO "%~2\%%~A" %ThisDepth%
49GOTO :EOF
50
51:DepthError
52ECHO ERROR: Invalid depth : %2
53EXIT /B 0
54
55:BitsError
56ECHO ERROR: Invalid hash_bits : %3
57EXIT /B 0
58