 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
JBensimon
Joined: 16 Nov 2004 Posts: 153 Location: New York
|
Posted: Tue Jun 09, 2009 3:06 am Post subject: Inconsistencies in "folder evaluation" tools? |
|
|
Whereas both
| Code: | | IfExist, \\server\share, ... | and
| Code: | | IfExist, \\server\share\, ... | return a positive result if "\\server\share" exists, both
| Code: | | FileExist("\\server\share") | and
| Code: | | FileExist("\\server\share\") | return an empty result (i.e. "not exist"), and the suggested technique for returning the long and short forms of a folder path
| Code: | Loop, \\server\share, 1
{
Long := A_LoopFileLongPath
Short := A_LoopFileShortPath
} | results in both variables Long and Short being empty (as would be the case if the target did not exist). As an aside, the same technique when used on an existing folder path with a trailing backslash also returns empty results, e.g.
| Code: | Loop, C:\Program Files\, 1
{
Long := A_LoopFileLongPath
Short := A_LoopFileShortPath
} | , but that's probably less important since it can easily be tested and corrected before entering the file loop.
Thanks as always,
Jacques. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10716
|
Posted: Wed Sep 16, 2009 10:51 pm Post subject: Re: Inconsistencies in "folder evaluation" tools? |
|
|
Sorry for the late reply.
I can't reproduce any difference in behavior between IfExist \\server\share and FileExist("\\server\share"). Both produce a TRUE result if the share-name exists. Furthermore both of them use essentially the same code internally, so any difference would be hard to explain.
Concerning Loop \\server\share, that uses the OS's FindFirstFile and FindNextFile functions, which apparently don't support the \\server\share syntax like GetFileAttributes() does (at least on some OSes), or there is something in the AutoHotkey code that prevents it from working (though I didn't notice anything when reviewing it). |
|
| Back to top |
|
 |
JBensimon
Joined: 16 Nov 2004 Posts: 153 Location: New York
|
Posted: Thu Sep 17, 2009 12:46 am Post subject: |
|
|
| Quote: | | Sorry for the late reply | Inexcusable!
| Quote: | | I can't reproduce any difference in behavior between IfExist \\server\share and FileExist("\\server\share") | I can't either any more. I may have been using an older AHK version ... or a hallucinogenic!
| Quote: | | Concerning Loop \\server\share, that uses the OS's FindFirstFile and FindNextFile functions, which apparently don't support the \\server\share syntax ... |
Upon further review, what's in fact happening is that the loop is skipped entirely when the parameter is a bare "\\server\share" without any further file or folder specification such as "\\server\share\folder", so the function (or its AHK implementation) treats "\\server\share" as non-existent. With "\\server\share\folder", the loop does work correctly, so the UNC syntax does seem to be supported by the API functions.
The "Loop, path\" problem is also a case of the loop being skipped entirely, so the trailing backslash also causes either the API call or the AHK code to not see the folder as existing.
Thanks for the reply.
Jacques. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|