- One way is two check the attributes of a folder and all of it's ancestor folders.
Based on this post by Builder:
Possible A_LoopFileLongPath bug - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 47#p194747
Based on these posts by Noesis:It also will loop over a file twice if Windows has more than one way of referencing the address....
example...
D:\Documents and Settings\Thomas\Desktop\STARTUP.ahk
D:\Users\Thomas\Desktop\STARTUP.ahk
Possible A_LoopFileLongPath bug - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 03#p195003
Possible A_LoopFileLongPath bug - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 52#p195052
Some code to compare two folders, which doesn't help to identify folder redirection on subfolders:
Code: Select all
;from winnt.h:
;FILE_ATTRIBUTE_READONLY := 0x1
;FILE_ATTRIBUTE_HIDDEN := 0x2
;FILE_ATTRIBUTE_SYSTEM := 0x4
;FILE_ATTRIBUTE_DIRECTORY := 0x10
;FILE_ATTRIBUTE_ARCHIVE := 0x20
;FILE_ATTRIBUTE_DEVICE := 0x40
;FILE_ATTRIBUTE_NORMAL := 0x80
;FILE_ATTRIBUTE_TEMPORARY := 0x100
;FILE_ATTRIBUTE_SPARSE_FILE := 0x200
;FILE_ATTRIBUTE_REPARSE_POINT := 0x400
;FILE_ATTRIBUTE_COMPRESSED := 0x800
;FILE_ATTRIBUTE_OFFLINE := 0x1000
;FILE_ATTRIBUTE_NOT_CONTENT_INDEXED := 0x2000
;FILE_ATTRIBUTE_ENCRYPTED := 0x4000
;FILE_ATTRIBUTE_INTEGRITY_STREAM := 0x8000
;FILE_ATTRIBUTE_VIRTUAL := 0x10000
;FILE_ATTRIBUTE_NO_SCRUB_DATA := 0x20000
;FILE_ATTRIBUTE_EA := 0x40000
;from:
;File Attribute Constants (Windows)
;https://msdn.microsoft.com/en-us/library/gg258117(v=vs.85).aspx
;FILE_ATTRIBUTE_RECALL_ON_OPEN := 0x40000
;FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS := 0x400000
;FileGetAttrib
;https://autohotkey.com/docs/commands/FileGetAttrib.htm
;R = READONLY
;A = ARCHIVE
;S = SYSTEM
;H = HIDDEN
;N = NORMAL
;D = DIRECTORY
;O = OFFLINE
;C = COMPRESSED
;T = TEMPORARY
;tested on Windows 7
;e.g. 0x2416, C:\Documents and Settings
;FILE_ATTRIBUTE_NOT_CONTENT_INDEXED := 0x2000
;FILE_ATTRIBUTE_REPARSE_POINT := 0x400
;FILE_ATTRIBUTE_DIRECTORY := 0x10
;FILE_ATTRIBUTE_SYSTEM := 0x4
;FILE_ATTRIBUTE_HIDDEN := 0x2
;tested on Windows 7
;e.g. 0x11, C:\Users
;FILE_ATTRIBUTE_DIRECTORY := 0x10
;FILE_ATTRIBUTE_READONLY := 0x1
q:: ;get file attributes
;vDir1 := "C:\Documents and Settings\" A_UserName "\Desktop"
;vDir2 := "C:\Users\" A_UserName "\Desktop"
vDir1 := "C:\Documents and Settings"
vDir2 := "C:\Users"
;MsgBox, % FileGetAttrib(vDir1) "`r`n" FileGetAttrib(vDir2)
MsgBox, % FileExist(vDir1) "`r`n" FileExist(vDir2)
vAttrib1 := DllCall("kernel32\GetFileAttributes", Str,vDir1, UInt)
vAttrib2 := DllCall("kernel32\GetFileAttributes", Str,vDir2, UInt)
MsgBox, % Format("0x{:X}`r`n0x{:X}", vAttrib1, vAttrib2)
return
- The attribute number should already be available in the WIN32_FIND_DATA structure that the AutoHotkey file loop uses. E.g. see this example for more details:
259-char path limit workarounds - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 06#p170806
- Here is an 'IsRedirected' function, although 'redirected' may or may not be the proper term for this.
Code: Select all
q:: ;is a file/folder redirected
vDir1 := "C:\Documents and Settings\" A_UserName "\Desktop"
vDir2 := "C:\Users\" A_UserName "\Desktop"
MsgBox, % IsRedirected(vDir1) ;0
MsgBox, % IsRedirected(vDir2) ;0
MsgBox, % IsRedirected(vDir1, 1) ;1
vDir1 := "C:\Documents and Settings"
vDir2 := "C:\Users"
MsgBox, % IsRedirected(vDir1) ;1
MsgBox, % IsRedirected(vDir2) ;0
return
IsRedirected(vPath, vDoRecurse:=0)
{
while InStr(vPath, "\")
{
vAttrib := DllCall("kernel32\GetFileAttributes", Str,vPath, UInt)
;FILE_ATTRIBUTE_REPARSE_POINT := 0x400
if (vAttrib & 0x400) && !(vAttrib = 0xFFFFFFFF)
return 1
if !vDoRecurse
return 0
SplitPath, vPath,, vPath
}
return 0
}