Rev 2 | Rev 5 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 4 | ||
---|---|---|---|
Line 18... | Line 18... | ||
18 | */ |
18 | */ |
19 | 19 | ||
20 | // This script generates SFV files |
20 | // This script generates SFV files |
21 | // If there is already an SFV file existing, only new files get appended to the existing SFV files. |
21 | // If there is already an SFV file existing, only new files get appended to the existing SFV files. |
22 | 22 | ||
- | 23 | // TODO: make use of STDERR and return different exit codes |
|
- | 24 | ||
23 | function _rec($directory) { |
25 | function _rec($directory) { |
24 | if (!is_dir($directory)) { |
26 | if (!is_dir($directory)) { |
25 | die("Invalid directory path $directory\n"); |
27 | die("Invalid directory path $directory\n"); |
26 | } |
28 | } |
27 | 29 | ||
Line 42... | Line 44... | ||
42 | 44 | ||
43 | $fullpath = $directory . '/' . $file; |
45 | $fullpath = $directory . '/' . $file; |
44 | if (is_dir($fullpath)) { |
46 | if (is_dir($fullpath)) { |
45 | _rec($fullpath); |
47 | _rec($fullpath); |
46 | } else { |
48 | } else { |
- | 49 | global $show_verbose; |
|
47 | ### echo "$fullpath\n"; |
50 | if ($show_verbose) echo "$fullpath\n"; |
48 | $dir = pathinfo($fullpath, PATHINFO_DIRNAME); |
51 | $dir = pathinfo($fullpath, PATHINFO_DIRNAME); |
49 | 52 | ||
50 | if (!file_exists($sfv_file)) { |
53 | if (!file_exists($sfv_file)) { |
51 | file_put_contents($sfv_file, "; Generated by ViaThinkSoft\r\n"); // TODO: BOM |
54 | file_put_contents($sfv_file, "; Generated by ViaThinkSoft\r\n"); // TODO: BOM |
52 | } |
55 | } |
Line 86... | Line 89... | ||
86 | return $out; |
89 | return $out; |
87 | } |
90 | } |
88 | 91 | ||
89 | # --- |
92 | # --- |
90 | 93 | ||
- | 94 | $show_verbose = false; |
|
- | 95 | $dir = ''; |
|
- | 96 | ||
- | 97 | for ($i=1; $i<$argc; $i++) { |
|
91 | if ($argc != 2) { |
98 | if ($argv[$i] == '-v') { |
- | 99 | $show_verbose = true; |
|
- | 100 | } else { |
|
- | 101 | $dir = $argv[$i]; |
|
- | 102 | } |
|
- | 103 | } |
|
- | 104 | ||
- | 105 | if (empty($dir)) { |
|
92 | echo "Syntax: $argv[0] <directory>\n"; |
106 | echo "Syntax: $argv[0] [-v] <directory>\n"; |
93 | exit(2); |
107 | exit(2); |
94 | } |
108 | } |
95 | 109 | ||
96 | if (!is_dir($argv[1])) { |
110 | if (!is_dir($dir)) { |
97 | echo "Directory not found\n"; |
111 | echo "Directory not found\n"; |
98 | exit(1); |
112 | exit(1); |
99 | } |
113 | } |
100 | 114 | ||
101 | _rec($argv[1]); |
115 | _rec($dir); |
102 | 116 | ||
103 | echo "Done.\n"; |
117 | if ($show_verbose) echo "Done.\n"; |