ron7 has asked for the wisdom of the Perl Monks concerning the following question:
My problem is files or directories with non Latin-1 chars in them. When run in the command line context, such files are "found". When run within the Tk GUI context, they are not!
I inserted a debug print into the File::List->new processing loop to display the directories being processed, with an else to print those which were neither -d, nor -f. The modified File::List->new is shown below (my mods in column zero):
sub new { my $class = shift; my $base = shift; my $self = {}; bless $self, $class; # store my base for later $self->{base} = $base; $debug && print "spawned with base [$base]\n"; # read in contents of current directory opendir (BASE, $base); my @entries = grep !/^\.\.?\z/, readdir BASE; chomp(@entries); closedir(BASE); for my $entry (@entries) { print "DEBUG: processing '$base/$entry'\n"; # if entry is a directory, launch a new File::List to explore it # and store a reference to the new object in the dirlist hash if (-d "$base/$entry") { $debug && print _trace(),"following directory $base/$entry\n"; my $newbase = new File::List("$base/$entry"); $self->{dirlist}{ $entry } = $newbase; } # if entry is a file, store it's name in the dirlist hash elsif ( -f "$base/$entry"){ $debug && print _trace(),"Found file : $base/$entry\n"; $self->{dirlist}{ $entry } = 1; } else { print "DEBUG: '$base/$entry' is not -f nor -d\n"; } } return $self; }
The console output in command-line mode is:
In Tk GUI mode we get:DEBUG: processing '/tmp/zumlaut//Zatôichi 01 - The Tale of Zatoichi (1 +962)' DEBUG: processing '/tmp/zumlaut//Zatôichi 01 - The Tale of Zatoichi (1 +962)/folder.jpg' DEBUG: processing '/tmp/zumlaut//Zatôichi 01 - The Tale of Zatoichi (1 +962)/VIDEO_TS' DEBUG: processing '/tmp/zumlaut//Zatôichi 01 - The Tale of Zatoichi (1 +962)/VIDEO_TS/fanart.jpg' DEBUG: processing '/tmp/zumlaut//Zatôichi 01 - The Tale of Zatoichi (1 +962)/VIDEO_TS/VIDEO_TS.TAG' DEBUG: processing '/tmp/zumlaut//Zatôichi 01 - The Tale of Zatoichi (1 +962)/backdrop.jpg' DEBUG: processing '/tmp/zumlaut//Zatôichi 01 - The Tale of Zatoichi (1 +962)/mymovies.xml' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/folder.jpg' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/BDMV' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/BDMV/index.TAG +' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/BDMV/fanart.jp +g' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/backdrop.jpg' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/mymovies.xml'
DEBUG: processing '/tmp/zumlaut//Zatôichi 01 - The Tale of Zatoichi (1 +962)' DEBUG: '/tmp/zumlaut//Zatôichi 01 - The Tale of Zatoichi (1962)' is no +t -f nor -d DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/folder.jpg' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/BDMV' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/BDMV/index.TAG +' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/BDMV/fanart.jp +g' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/backdrop.jpg' DEBUG: processing '/tmp/zumlaut//Pan's Labyrinth (2006)/mymovies.xml'
Note that the path with the utf-8 char in it is not recognized as a directory. Apparently *Something* introduced by the Tk environment is preventing the -d test from returning true.
I've tried a few things, but to no avail. Suggestions or helpful references MOST welcome!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File::List, UTF-8, and Tk
by Anonymous Monk on Apr 28, 2011 at 03:20 UTC | |
|
Re: File::List, UTF-8, and Tk
by ron7 (Beadle) on Apr 28, 2011 at 04:06 UTC | |
by Anonymous Monk on Apr 28, 2011 at 04:14 UTC | |
by ron7 (Beadle) on Apr 28, 2011 at 04:45 UTC | |
by ron7 (Beadle) on Apr 29, 2011 at 02:07 UTC |