If you want to get an idea of what exactly is going on, here's the source for both
A_LoopFileFullPath and
A_LoopFileLongPath and some notes of interest:
[color=black]VarSizeType BIV_LoopFileFullPath(char *aBuf, char *aVarName)[/color]
{
[color=green]// The loop handler already prepended the script's directory in cFileName for us:[/color]
char *full_path = g->mLoopFile ? g->mLoopFile->cFileName : "";
if (aBuf)
strcpy(aBuf, full_path);
return (VarSizeType)strlen(full_path);
}
[color=black]VarSizeType BIV_LoopFileLongPath(char *aBuf, char *aVarName)[/color]
{
char *unused, buf[MAX_PATH] = ""; [color=green]// Set default.[/color]
if (g->mLoopFile)
{
[color=green]// GetFullPathName() is done in addition to ConvertFilespecToCorrectCase() for the following reasons:
// 1) It's currrently the only easy way to get the full path of the directory in which a file resides.
// For example, if a script is passed a filename via command line parameter, that file could be
// either an absolute path or a relative path. If relative, of course it's relative to A_WorkingDir.
// The problem is, the script would have to manually detect this, which would probably take several
// extra steps.
// 2) A_LoopFileLongPath is mostly intended for the following cases, and in all of them it seems
// preferable to have the full/absolute path rather than the relative path:
// a) Files dragged onto a .ahk script when the drag-and-drop option has been enabled via the Installer.
// b) Files passed into the script via command line.
// The below also serves to make a copy because changing the original would yield
// unexpected/inconsistent results in a script that retrieves the A_LoopFileFullPath
// but only conditionally retrieves A_LoopFileLongPath.[/color]
if (!GetFullPathName(g->mLoopFile->cFileName, MAX_PATH, buf, &unused))
*buf = '\0';[color=green] // It might fail if NtfsDisable8dot3NameCreation is turned on in the registry, and possibly for other reasons.[/color]
else
[color=green]// The below is called in case the loop is being used to convert filename specs that were passed
// in from the command line, which thus might not be the proper case (at least in the path
// portion of the filespec), as shown in the file system:[/color]
ConvertFilespecToCorrectCase(buf);
}
if (aBuf)
strcpy(aBuf, buf); [color=green]// v1.0.47: Must be done as a separate copy because passing a size of MAX_PATH for aBuf can crash when aBuf is actually smaller than that (even though it's large enough to hold the string). This is true for ReadRegString()'s API call and may be true for other API calls like the one here.[/color]
return (VarSizeType)strlen(buf); [color=green]// Must explicitly calculate the length rather than using the return value from GetFullPathName(), because ConvertFilespecToCorrectCase() expands 8.3 path components.[/color]
}