AutoHotkey Community

It is currently May 26th, 2012, 10:45 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: June 9th, 2009, 4:06 am 
Offline

Joined: November 16th, 2004, 6:38 am
Posts: 153
Location: New York
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.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: September 16th, 2009, 11:51 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 17th, 2009, 1:46 am 
Offline

Joined: November 16th, 2004, 6:38 am
Posts: 153
Location: New York
Quote:
Sorry for the late reply
Inexcusable! :D
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group