Fixed - FileInstall command does not respect A_WorkingDir

Report problems with documented functionality
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Fixed - FileInstall command does not respect A_WorkingDir

13 Jul 2014, 02:04

FileInstall does not respect A_WorkingDir when copying files to a new destination.
However it does respect A_WorkingDir when it is compiled.

Code: Select all

SetWorkingDir, Bilder/
FileInstall, Bilder/a1AjOQ8_460sa.gif,a1AjOQ8_460sa.gif,1
The Picture in this example will end up in the Scripts dir when its not compiled.
Recommends AHK Studio
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: FileInstall command does not respect A_WorkingDir

13 Jul 2014, 04:17

AutoHotkey Help - Source wrote:The name of the file to be added to the compiled EXE. The file is assumed to be in (or relative to) the script's own directory if an absolute path isn't specified.

The file name must not contain double quotes, variable references (e.g. %A_ProgramFiles%), or wildcards...
Why do you think it is a bug?
Ahk2Exe cannot know what the working directory of a script is!
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: FileInstall command does not respect A_WorkingDir

13 Jul 2014, 04:31

Maybe I didn't express myself properly.
I'm sorry if that's the case.
I am aware of the reasons why the source Parameter is the way it is.
However I'm talking about the destination Parameter, in the Script Version.
It does not react to any change of A_WorkingDir even though the Help File States:
When Source is extracted from the EXE, this is the name of the file to be created. It is assumed to be in %A_WorkingDir% if an absolute path isn't specified. The destination directory must already exist. Unlike Source, variable references may be used.
Recommends AHK Studio
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: FileInstall command does not respect A_WorkingDir

13 Jul 2014, 04:41

I see, that should be easy to fix:

Code: Select all

ResultType Line::FileInstall(LPTSTR aSource, LPTSTR aDest, LPTSTR aFlag)
{
...
else
	{
		// v1.0.35.11: Must search in A_ScriptDir by default because that's where ahk2exe will search by default.
		// The old behavior was to search in A_WorkingDir, which seems pointless because ahk2exe would never
		// be able to use that value if the script changes it while running.
		TCHAR aDestPath[MAX_PATH];
		GetFullPathName(aDest, MAX_PATH, aDestPath, NULL);
		SetCurrentDirectory(g_script.mFileDir);
		success = CopyFile(aSource, aDestPath, !allow_overwrite);
		SetCurrentDirectory(g_WorkingDir); // Restore to proper value.
	}
#endif

	return SetErrorLevelOrThrowBool(!success);
}
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: FileInstall command does not respect A_WorkingDir

30 Jul 2014, 02:25

Care to submit a patch, HotKeyIt?
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: FileInstall command does not respect A_WorkingDir

01 Aug 2014, 19:58

Patch merged in v1.1.15.03.

Return to “Bug Reports”

Who is online

Users browsing this forum: Google [Bot] and 84 guests