Re: I need help with .IO.d.Bool
[email protected] (ToddAndMargo via perl6-users) Sat, 5 Apr 2025 18:58:57 -0700
| Newsgroups | perl.perl6.users |
|---|---|
| Message-ID | <[email protected]> |
On 4/2/25 6:08 PM, Bruce Gray wrote: > > >> On Apr 2, 2025, at 19:47, ToddAndMargo via perl6-users <[email protected]> wrote: > > --snip-- > >> raku -e "say '\\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1'.IO.d.Bool;" >> False > > --snip-- > > Moving this one-liner into a .raku file (to remove the complication of Windows needing double-quotes for our `-e`), and removing `.IO.d.Bool`, I ran just this line: > say '\\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1'; > The output is: > \192.168.240.10\oldserver\Backup\MyDocsBackup\backup1 > So, the initial two backslashes are becoming a single backslash. > You need a quoting that does not special-case doubled backslashes (like the Q[] I have seen you use), or to enter the path with initial quadruple backslashes. > > Does changing your one-liner to this: > raku -e "say Q[\\192.168.240.10\oldserver\Backup\MyDocsBackup\backup1].IO.d.Bool;" > fix the problem? > If not, remove the `.Bool` just for a test run. You might still get False (like if the path exists but is not a directory), or you might get a Exception that gives you more detail of what is going wrong (like `Failed to find ...`, with the exact path that it was *actually* looking for). > Hi Bruce, I need the function to operate with the exact path assigned by Windows. No adding or subtracting. This was my work around: sub Directory( Str $DriveDirectory ) returns Bool is export( :Directory ) { # True if a Directory or Drive Letter my Str $RtnStr = RunCmd( "powershell.exe test-path -Path " ~ Q["] ~ $DriveDirectory ~ Q["] ~ " -PathType Container", True ); # print "RtnStr = <$RtnStr>\n"; if $RtnStr.lc.starts-with( "true" ) { return True; } else { return False; } } Notice that I did not have to mess the `$DriveDirectory`? .IO.d.Bool needs to do the same. Let me know if you want the code for `RunCmd`. Thank you for the help, -T