Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2009-02

wrong behaviuor of GetAppConfigDir

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ik

Hello,

GetAppConfigDir takes the title of the application in order to set the directory where the project will store it's configuration.

This type of behavior is wrong because of:
1. Translating of a program (for example for Hebrew in my case) will result in different directory
2. The title of the application might change depending on things inside the program itself.
3. Possible of unsupported chars to be part of the directory name.

My suggestion is to do the following (it's a proof of concept and not the real code):

function GetAppConfigDir(global : Boolean; AName : String = '') : String;
var
  Path : String;
  HomeDirectory : String;
begin
  HomeDirecory := ...
  if global then
    path := ...
  else
    path := HomeDirectory
  if Trim(AName)  '' then
   Result := path + DirectorySeperator + Trim(AName)
  else
   Result := path + DirectorySeperator + ExeName
end;

What do you think of it for next versions of FPC ?

Thanks,
Ido

Reply by email

Michael Van Canneyt
to ik
ik wrote 10 lines
Hello, GetAppConfigDir takes the title of the application in order to set the directory where the project will store it's configuration. This type of behavior is wrong because of: 1. Translating of a program (for example for Hebrew in my case) will result in different directory 2. The title of the application might change depending on things inside the program itself.

The title is not used, but the binary name.

3. Possible of unsupported chars to be part of the directory name.

To avoid this, set the 'OnGetApplicationName' hook, and provide a name.

So you see, the points you mention were foreseen :-)

Michael.

Reply by email