in reply to How to test if a file is readable on Win64?

Hi , I have some ideas :)

Unfortunately this doesn't work on Windows resulting in my script crashing due to Permission Denied trying to read a protected file.

Try Win32API::File , for example

sub is_readable { use Win32API::File (); my $oldMode = Win32API::File::SetErrorMode(2); my $readable = -r $_[0]; Win32API::File::SetErrorMode( $oldMode ); return $readable; }

Also try cacls.exe for changing permissions ...

Also, I remember hearing about starting win32 programs with "dropped privileges" (psexec.exe -d -l ) ... so the program doesn't use all the permissions you have ... :)

Thats my ideas

Replies are listed 'Best First'.
Re^2: How to test if a file is readable on Win64?
by rhardy (Acolyte) on Mar 10, 2014 at 01:16 UTC
    Unfortunately this did not seem to work. I implemented your suggestions but my script fails in the exact same way i.e. it gets to a file which it cannot read but the is_readable function returns that it is readable and my program proceeds to try and execute code which can't possibly succeed i.e. diffing two files, one of which it can't read.