On 2020-04-03 13:33, ToddAndMargo via perl6-users wrote:
On 2020-04-03 13:27, ToddAndMargo via perl6-users wrote:
On 2020-04-03 13:12, ToddAndMargo via perl6-users wrote:
On 2020-04-01 18:59, ToddAndMargo via perl6-users wrote:
Hi All,
In Windows, is there a way to get
$FileName.IO.e.Bool
to show hidden files?
attrib C:\pagefile.sys
A SH C:\pagefile.sys
raku -e "say 'c:\\pagefile.sys'.IO.e.Bool;"
False
raku -e "say 'c:\pagefile.sys'.IO.e.Bool;"
False
Many thanks,
-T
I just opened:
IO.e.Bool misses hidden files:
https://github.com/rakudo/rakudo/issues/3594
Workaround:
raku -e "my $x='C:\pagefile.sys'; say qqx ( attrib $x ).contains( $x );"
True
And to make it more Windows friendly, where file names
are not case sensitive:
raku -e "my $x='C:\PageFile.SYS'.lc; say qqx ( attrib $x
).lc.contains( $x );"
True
That workaround does not work right. Here is
a better one:
Workaround:
raku -e "my $x='C:\pagefile.sys'; say qqx ( attrib $x ).words[2] eq
$x ;"
True
raku -e "my $x='C:\pagefile.sysx'; say qqx ( attrib $x ).words[2]
eq $x ;"
False
Even better for file name cases in Wiodws:
raku -e "my $x='C:\pagefile.sys'; say qqx ( attrib $x ).words[2].lc
eq $x.lc ;"
True
raku -e "my $x='C:\pagefile.sysx'; say qqx ( attrib $x ).words[2].lc
eq $x.lc ;"
False
And it gets uglier. qqx has a bug where it does no
interpret quotes correctly:
qqx, shell not operating quotes properly:
https://github.com/rakudo/rakudo/issues/3518
But I got there eventually. This worked:
if @*ARGS.elems > 0 {
$FileName = lc "@*ARGS[0]";
$FileName2 = Q["] ~ $FileName ~ Q["];
}
$CmdStr =
Q[@echo off] ~ "\n" ~
Q[attrib ] ~
$FileName2 ~
"\n";
# say $CmdStr;
spurt( $BatFile, $CmdStr );
$Attribs = qqx { $BatFile };
# say "FileName <$FileName2>\nAttribs <$Attribs>\n";
if $Attribs.contains( "not found" ) ||
$Attribs.lc.contains( $FileName.lc ) eq False {
$MsgStr = $FileName ~ " does not exist\n";
say $MsgStr;
MessageBox( "$IAm", $MsgStr, MB_ICONWARNING, MB_OK );
exit;
}