osutil.inc 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by the Free Pascal development team
  5. <What does this file>
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. { ---------------------------------------------------------------------
  13. Application name
  14. ---------------------------------------------------------------------}
  15. Function ApplicationName : String;
  16. begin
  17. If Assigned(OnGetApplicationName) then
  18. Result:=OnGetApplicationName()
  19. else
  20. Result:=ChangeFileExt(ExtractFileName(Paramstr(0)),'');
  21. end;
  22. { ---------------------------------------------------------------------
  23. Default implementations for AppConfigDir implementation.
  24. ---------------------------------------------------------------------}
  25. Function DGetAppConfigDir(Global : Boolean) : String;
  26. begin
  27. Result:=ExcludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0)));
  28. end;
  29. Function DGetAppConfigFile(Global : Boolean; SubDir : Boolean) : String;
  30. begin
  31. Result:=ExtractFilePath(ParamStr(0));
  32. If SubDir then
  33. Result:=IncludeTrailingPathDelimiter(Result+ApplicationName);
  34. Result:=Result+ApplicationName+ConfigExtension;
  35. end;
  36. Function GetAppConfigFile(Global : Boolean) : String;
  37. begin
  38. Result:=GetAppConfigFile(Global,False);
  39. end;
  40. { ---------------------------------------------------------------------
  41. Fallback implementations for AppConfigDir implementation.
  42. ---------------------------------------------------------------------}
  43. {
  44. If a particular OS does it different:
  45. - set the HAVE_OSCONFIG define before including sysutils.inc.
  46. - implement the functions.
  47. Default config assumes a DOS-like configuration.
  48. }
  49. {$ifndef HAS_OSCONFIG}
  50. Function GetAppConfigDir(Global : Boolean) : String;
  51. begin
  52. Result:=DGetAppConfigDir(Global);
  53. end;
  54. Function GetAppConfigFile(Global : Boolean; SubDir : Boolean) : String;
  55. begin
  56. Result:=DGetAppConfigFile(Global,Subdir);
  57. end;
  58. {$endif}
  59. {
  60. $Log$
  61. Revision 1.1 2004-08-05 07:28:01 michael
  62. + Added getappconfigdir calls
  63. }