5 # process command line arguments
6 while ($ARGV[0] =~ /^-/)
14 elsif ($_ eq "--delete")
20 die "unknown command line option";
24 sub CollectP4OpenedFiles
26 open(P4
, "p4 opened |");
30 $openedFiles{$_} = 1 if (s/#.*//);
39 # found a directory entry
41 # prune the directory if it's one we want to ignore
42 if (m/^(compile|external|Debug|Optimized|Production|Release|generated)$/)
45 $File::Find
::prune
= 1;
46 print STDERR
"[Pruned Directory Entry: $File::Find::name]\n" if ($debug);
51 # handle writable non-directory entry
52 if (!m/^.*(\.(aps|ca|clw|class|dll|ews|exe|ncb|opt|plg|WW|tmp|db|bak|pyc|cfg|o)|~)$/)
54 # this is a writable file that should be checked against what's in Perforce.
55 my ($commandLine, $expectedDepotLocation);
57 $commandLine = `p4 where $File::Find::name`;
58 $commandLine =~ /([^ ]+) /;
60 $expectedDepotLocation = $1;
62 # this writable file is suspect (i.e. is missing) if the depot file
63 # is not opened. That implies the file is writable but not opened,
64 # most likely indicating it doesn't exist in the depot.
65 if (!$openedFiles{$expectedDepotLocation})
67 print $File::Find
::name
, "\n";
68 unlink $File::Find
::name
if ($delete);
72 print STDERR
"<file [$File::Find::name] is in perforce>\n" if ($debug);
78 # collect opened depot files
79 CollectP4OpenedFiles
();
82 @ARGV = ('../') unless @ARGV;
83 find
(\
&FindHandler
, @ARGV);