Skip Menu |

This queue is for tickets about the Tk-JFileDialog CPAN distribution.

Report information
The Basics
Id: 125544
Status: resolved
Priority: 0/
Queue: Tk-JFileDialog

People
Owner: turnerjw784 [...] yahoo.com
Requestors: tlhackque [...] yahoo.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 2.0



Subject: Divots on Windows
Date: Sun, 10 Jun 2018 06:16:15 -0400
To: bug-Tk-JFileDialog [...] rt.cpan.org
From: tlhackque <tlhackque [...] yahoo.com>
Tk::JFileDialog::VERSION == 1.62 windows 10 Pro Two issues with Windoze compatibility: First: The hidden button does not inspect the Windows "hidden file" attribute. So "/" shows the Windows volume label, recycle bin, etc. Here's how to do that portably (tested on Windows & Linux): +++++++++++++++ #!perl use warnings; use strict; use File::Spec; my $windows; BEGIN { if( $^O eq 'MSWin32' ) { require Win32::File; Win32::File->import( qw/HIDDEN/ ); $windows = 1; } } my $dir = 'F:/'; my @path = File::Spec->splitpath( $dir ); opendir( DIR, $dir ) or die "Couldn't open $main::DIR: $!\n"; my @vis_files; foreach my $file (readdir(DIR)) { if( $windows ) { my $attrs; my $path = File::Spec::->catfile( @path, $file ); next unless( Win32::File::GetAttributes( $path, $attrs ) ); # Call fails next if( $attrs & HIDDEN() ); # Hidden file } else { # You may want to do the following unconditionally # since non-native programs on Windows also use dotfile # convention... next if( $file =~ /^\./ ); } push @vis_files, $file; } closedir( DIR ) or warn "Couldn't close $main::DIR: $!\n"; print $_, $/ for @vis_files; +++++++++++++++ The code is written for clarity, not style. note that readdir() in list context may return a VERY large list. while( defined( my $file =readdir( DIR ) ) would be safer. Thanks to https://www.perlmonks.org/?node_id=194011 for showing how to do the windows-specific stuff. Second issue: The dialog box gets confused if the default path for a device isn't '/'. On windows, C:\me> CD F:/foo/baz will make C:\me> dir F:blork/f.txt reference F:/foo/baz/blork/f.txt. If you run a script using Tk::JFileDialog in this condition, this confuses the widget. It seems to think that F: is the same as F:/
Fixed in v2.0, just released. Jim. On Sun Jun 10 06:16:40 2018, tlhackque wrote: Show quoted text
> Tk::JFileDialog::VERSION == 1.62 > > windows 10 Pro > > Two issues with Windoze compatibility: > > First: > The hidden button does not inspect the Windows "hidden file" attribute. > So "/" shows the Windows volume label, recycle bin, etc. > > Here's how to do that portably (tested on Windows & Linux): > +++++++++++++++ > #!perl > > use warnings; > use strict; > > use File::Spec; > my $windows; > BEGIN { > if( $^O eq 'MSWin32' ) { > require Win32::File; > Win32::File->import( qw/HIDDEN/ ); > $windows = 1; > } > } > > > my $dir = 'F:/'; > > my @path = File::Spec->splitpath( $dir ); > > opendir( DIR, $dir ) or die "Couldn't open $main::DIR: $!\n"; > > my @vis_files; > > foreach my $file (readdir(DIR)) { > if( $windows ) { > my $attrs; > my $path = File::Spec::->catfile( @path, $file ); > next unless( Win32::File::GetAttributes( $path, $attrs ) ); # > Call fails > next if( $attrs & HIDDEN() ); # Hidden file > } else { # You may want to do the following unconditionally > # since non-native programs on Windows also use dotfile > # convention... > next if( $file =~ /^\./ ); > } > push @vis_files, $file; > } > closedir( DIR ) or warn "Couldn't close $main::DIR: $!\n"; > > print $_, $/ for @vis_files; > +++++++++++++++ > > The code is written for clarity, not style. > note that readdir() in list context may return a VERY large > list. while( defined( my $file =readdir( DIR ) ) would be > safer. > > Thanks to https://www.perlmonks.org/?node_id=194011 for showing > how to do the windows-specific stuff. > > Second issue: The dialog box gets confused if the default path for a > device isn't '/'. > > On windows, > C:\me> CD F:/foo/baz > will make > C:\me> dir F:blork/f.txt > reference F:/foo/baz/blork/f.txt. > > If you run a script using Tk::JFileDialog in this > condition, this confuses the widget. It seems to > think that F: is the same as F:/
On Fri Jul 13 02:11:56 2018, TURNERJW wrote: Show quoted text
> Fixed in v2.0, just released. > > Jim. > > On Sun Jun 10 06:16:40 2018, tlhackque wrote:
> > Tk::JFileDialog::VERSION == 1.62 > > > > windows 10 Pro > > > > Two issues with Windoze compatibility: > > > > First: > > The hidden button does not inspect the Windows "hidden file" attribute. > > So "/" shows the Windows volume label, recycle bin, etc. > > > > Here's how to do that portably (tested on Windows & Linux): > > +++++++++++++++ > > #!perl > > > > use warnings; > > use strict; > > > > use File::Spec; > > my $windows; > > BEGIN { > > if( $^O eq 'MSWin32' ) { > > require Win32::File; > > Win32::File->import( qw/HIDDEN/ ); > > $windows = 1; > > } > > } > > > > > > my $dir = 'F:/'; > > > > my @path = File::Spec->splitpath( $dir ); > > > > opendir( DIR, $dir ) or die "Couldn't open $main::DIR: $!\n"; > > > > my @vis_files; > > > > foreach my $file (readdir(DIR)) { > > if( $windows ) { > > my $attrs; > > my $path = File::Spec::->catfile( @path, $file ); > > next unless( Win32::File::GetAttributes( $path, $attrs ) ); # > > Call fails > > next if( $attrs & HIDDEN() ); # Hidden file > > } else { # You may want to do the following unconditionally > > # since non-native programs on Windows also use dotfile > > # convention... > > next if( $file =~ /^\./ ); > > } > > push @vis_files, $file; > > } > > closedir( DIR ) or warn "Couldn't close $main::DIR: $!\n"; > > > > print $_, $/ for @vis_files; > > +++++++++++++++ > > > > The code is written for clarity, not style. > > note that readdir() in list context may return a VERY large > > list. while( defined( my $file =readdir( DIR ) ) would be > > safer. > > > > Thanks to https://www.perlmonks.org/?node_id=194011 for showing > > how to do the windows-specific stuff. > > > > Second issue: The dialog box gets confused if the default path for a > > device isn't '/'. > > > > On windows, > > C:\me> CD F:/foo/baz > > will make > > C:\me> dir F:blork/f.txt > > reference F:/foo/baz/blork/f.txt. > > > > If you run a script using Tk::JFileDialog in this > > condition, this confuses the widget. It seems to > > think that F: is the same as F:/
> >