Rev 4 | Rev 11 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4 | Rev 5 | ||
---|---|---|---|
Line 33... | Line 33... | ||
33 | $existing_files = md5_get_files($md5_file); |
33 | $existing_files = md5_get_files($md5_file); |
34 | } else { |
34 | } else { |
35 | $existing_files = array(); |
35 | $existing_files = array(); |
36 | } |
36 | } |
37 | 37 | ||
- | 38 | $sd = @scandir($directory); |
|
- | 39 | if ($sd === false) { |
|
- | 40 | echo "Error: Cannot scan directory $directory\n"; |
|
- | 41 | return; |
|
- | 42 | } |
|
- | 43 | ||
38 | foreach (scandir($directory) as $file) { |
44 | foreach ($sd as $file) { |
39 | if ($file === '.') continue; |
45 | if ($file === '.') continue; |
40 | if ($file === '..') continue; |
46 | if ($file === '..') continue; |
41 | if (strtolower($file) === 'thumbs.db') continue; |
47 | if (strtolower($file) === 'thumbs.db') continue; |
42 | if (substr($file, -4) === '.md5') continue; |
48 | if (strtolower(substr($file, -4)) === '.md5') continue; |
43 | if (substr($file, -4) === '.sfv') continue; |
49 | if (strtolower(substr($file, -4)) === '.sfv') continue; |
44 | 50 | ||
45 | $fullpath = $directory . '/' . $file; |
51 | $fullpath = $directory . '/' . $file; |
46 | if (is_dir($fullpath)) { |
52 | if (is_dir($fullpath)) { |
47 | _rec($fullpath); |
53 | _rec($fullpath); |
48 | } else { |
54 | } else if (is_file($fullpath)) { |
49 | global $show_verbose; |
55 | global $show_verbose; |
50 | if ($show_verbose) echo "$fullpath\n"; |
56 | if ($show_verbose) echo "$fullpath\n"; |
51 | $dir = pathinfo($fullpath, PATHINFO_DIRNAME); |
57 | $dir = pathinfo($fullpath, PATHINFO_DIRNAME); |
52 | 58 | ||
53 | if (!file_exists($md5_file)) { |
59 | if (!file_exists($md5_file)) { |
Line 56... | Line 62... | ||
56 | 62 | ||
57 | if (!in_array($file, $existing_files)) { |
63 | if (!in_array($file, $existing_files)) { |
58 | $md5 = strtolower(md5_file($fullpath)); |
64 | $md5 = strtolower(md5_file($fullpath)); |
59 | file_put_contents($md5_file, "$md5 *$file\r\n", FILE_APPEND); |
65 | file_put_contents($md5_file, "$md5 *$file\r\n", FILE_APPEND); |
60 | } |
66 | } |
- | 67 | } else { |
|
- | 68 | // For some reason, some files on a NTFS volume are "FIFO" pipe files?! |
|
- | 69 | echo "Warning: $fullpath is not a regular file!\n"; |
|
61 | } |
70 | } |
62 | } |
71 | } |
63 | } |
72 | } |
64 | 73 | ||
65 | function md5_get_files($filename) { |
74 | function md5_get_files($filename) { |