Yams
14-Aug-2008, 08:49 PM
procedure OpenLogFile;
...
if (Cached_LogFile = nil) then
begin
Opened_LogFile_Name := ExpandEnvVars(CurrentOptions.OutputLogFile(''));
Cached_LogFile := TLogFile.Create(Opened_LogFile_Name, False);
end;
end;
TEurekaModuleOptions.OutputLogFile
TEurekaModuleOptions.OutputFile
GetWorkingFile
IsFileOK
IsWritableFile:
...
HFile := CreateFile(PChar(FileName), GENERIC_WRITE or GENERIC_READ,
FILE_SHARE_READ or FILE_SHARE_WRITE, nil,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); // <- here
if (HFile <> INVALID_HANDLE_VALUE) then
...
If you set log file output path option to "%AppData%\MyAppsLogFiles" then you will have 2 problems:
1). Create file does not work with environment variables. You should expand variables earlier.
2). Folder %AppData%\MyAppsLogFiles obiosly does not exists. You should do ForceDirectories before call to IsFileOK.
As a workaround I must manually (in running program) initialize this option.
...
if (Cached_LogFile = nil) then
begin
Opened_LogFile_Name := ExpandEnvVars(CurrentOptions.OutputLogFile(''));
Cached_LogFile := TLogFile.Create(Opened_LogFile_Name, False);
end;
end;
TEurekaModuleOptions.OutputLogFile
TEurekaModuleOptions.OutputFile
GetWorkingFile
IsFileOK
IsWritableFile:
...
HFile := CreateFile(PChar(FileName), GENERIC_WRITE or GENERIC_READ,
FILE_SHARE_READ or FILE_SHARE_WRITE, nil,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); // <- here
if (HFile <> INVALID_HANDLE_VALUE) then
...
If you set log file output path option to "%AppData%\MyAppsLogFiles" then you will have 2 problems:
1). Create file does not work with environment variables. You should expand variables earlier.
2). Folder %AppData%\MyAppsLogFiles obiosly does not exists. You should do ForceDirectories before call to IsFileOK.
As a workaround I must manually (in running program) initialize this option.