Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Windows folder access error ($^E)

by tye (Sage)
on Oct 24, 2014 at 14:45 UTC ( [id://1104873]=note: print w/replies, xml ) Need Help??


in reply to Windows folder access error

Add $^E to your error report and you might get a better idea what is going wrong.

My only guess is that your script is running in a context where it doesn't have a current "working drive" and if you prepend the "C:" to your string, that it might fix the problem.

You can see the code that is producing this error at p5git://win32/win32.c., in particular:

dirp->handle = FindFirstFileW(PerlDir_mapW(wscanname), &wFindData) +; if (dirp->handle == INVALID_HANDLE_VALUE) { DWORD err = GetLastError(); /* FindFirstFile() fails on empty drives! */ switch (err) { case ERROR_FILE_NOT_FOUND: return dirp; case ERROR_NO_MORE_FILES: case ERROR_PATH_NOT_FOUND: errno = ENOENT; break; case ERROR_NOT_ENOUGH_MEMORY: errno = ENOMEM; break; default: errno = EINVAL; break; } Safefree(dirp); return NULL; }

So EINVAL (invalid argument) just means "not ERROR_NO_MORE_FILES, ERROR_PATH_NOT_FOUND, nor ERROR_NOT_ENOUGH_MEMORY". $^E should tell you what GetLastError() returned.

- tye        

Replies are listed 'Best First'.
Re^2: Windows folder access error ($^E)
by ArifS (Beadle) on Oct 24, 2014 at 16:21 UTC
    I can use "." as root folder, and the script works just fine.
    I can also get to the folder from cmd using -
    \Folders\1Folder\1aFolder
    So, it's a valid path for windows. It seems like doesn't like the folder command.

    Please let me know.
      I can use "." as root folder, and the script works just fine.
      Can you rephrase what you mean by that and why u cannot use the "." in your script to rectify the (relative path) issue ? : Its obvious as anything the path/relative path is not getting resolved,for which you need to do the error checking mentioned above.
      are u running the script from cmd prompt ?
      if so what is the output of your pwd (present working directory)command ? and
      is ure script able to run in a non-windows environment(if you have the luxury of checking that)
      Do not wait to strike when the iron is hot! Make it hot by striking - WB Yeats

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1104873]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 07:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found