source: test-collections/trunk/filename-encodings/script/dirlist.pl@ 23325

Last change on this file since 23325 was 23325, checked in by davidb, 11 years ago

Utility scripts that help study how the file system is representing the filenames

File size: 1.0 KB
Line 
1#!/usr/bin/perl -w
2
3
4sub debug_unicode_string
5{
6 join("",
7 map { $_ > 128 ? # if wide character...
8 sprintf("\\x{%04X}", $_) : # \x{...}
9 chr($_)
10 } unpack("U*", $_[0])); # unpack Unicode characters
11}
12
13
14if (scalar(@ARGV)!=1) {
15 my $prog_name = $0;
16 $prog_name =~ s/^.*(\\|\/)//;
17
18 print STDERR "Usage: $prog_name dir\n";
19 exit(1);
20}
21
22my $dir = $ARGV[0];
23
24opendir(DIN,"$dir")
25 || die "Unable to open $dir";
26
27my @files = grep { $_ !~ m/^\./ } readdir(DIN);
28
29close(DIN);
30
31#open(FOUT,">file-list.txt")
32# || die "Unable to open file-list.txt";
33
34foreach my $f (@files)
35{
36 print "Filename as is: $f\n";
37 print "Filename debug: ", debug_unicode_string($f),"\n";
38
39 my $dirsep = ($^O =~ /mswin/i) ? "\\" : "/";
40
41 $dirsep =~ s@$dirsep$@@;
42
43 if ( -e "$dir$dirsep$f" ) {
44 print " Perl can see file $dir$dirsep$f\n";
45 }
46 else {
47 print " Perl CANNOT see $dir$dirsep$f\n";
48 }
49# print FOUT "$f\n";
50}
51
52#close(FOUT);
Note: See TracBrowser for help on using the repository browser.