fina.inc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. {
  2. *********************************************************************
  3. $Id$
  4. Copyright (C) 1997, 1998 Gertjan Schouten
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. *********************************************************************
  17. System Utilities For Free Pascal
  18. }
  19. type
  20. PByte=^Byte;
  21. PWord=^Word;
  22. PLongint=^Longint;
  23. const
  24. DayTable:array[Boolean,1..12] of longint =
  25. ((0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334),
  26. (0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335));
  27. HexDigits: array[0..15] of char = '0123456789ABCDEF';
  28. function ChangeFileExt(FileName, Extension: string): string;
  29. var i: longint;
  30. begin
  31. I := Length(FileName);
  32. while (I > 0) and not (FileName[I] in ['.', '\', ':']) do Dec(I);
  33. if (I = 0) or (FileName[I] <> '.') then I := 255;
  34. ChangeFileExt := Copy(FileName, 1, I - 1) + Extension;
  35. end;
  36. function ExtractFilePath(FileName: string): string;
  37. var i: longint;
  38. begin
  39. i := Length(FileName);
  40. while (I > 0) and not (FileName[I] in ['\', ':']) do Dec(I);
  41. ExtractFilePath := Copy(FileName, 1, I);
  42. end;
  43. function ExtractFileDir(FileName: string): string;
  44. var i: longint;
  45. begin
  46. I := Length(FileName);
  47. while (I > 0) and not (FileName[I] in ['\', ':']) do Dec(I);
  48. if (I > 1) and (FileName[I] = '\') and
  49. not (FileName[I - 1] in ['\', ':']) then Dec(I);
  50. ExtractFileDir := Copy(FileName, 1, I);
  51. end;
  52. function ExtractFileDrive(FileName: string): string;
  53. var i, j: longint;
  54. begin
  55. if (Length(FileName) >= 3) and (FileName[2] = ':') then
  56. ExtractFileDrive := Copy(FileName, 1, 2)
  57. else if (Length(FileName) >= 2) and (FileName[1] = '\') and
  58. (FileName[2] = '\') then begin
  59. J := 0;
  60. I := 3;
  61. While (I < Length(FileName)) and (J < 2) do begin
  62. if FileName[I] = '\' then Inc(J);
  63. if J < 2 then Inc(I);
  64. end;
  65. if FileName[I] = '\' then Dec(I);
  66. ExtractFileDrive := Copy(FileName, 1, I);
  67. end else ExtractFileDrive := '';
  68. end;
  69. function ExtractFileName(FileName: string): string;
  70. var i: longint;
  71. begin
  72. I := Length(FileName);
  73. while (I > 0) and not (FileName[I] in ['\', ':']) do Dec(I);
  74. ExtractFileName := Copy(FileName, I + 1, 255);
  75. end;
  76. function ExtractFileExt(FileName: string): string;
  77. var i: longint;
  78. begin
  79. I := Length(FileName);
  80. while (I > 0) and not (FileName[I] in ['.', '\', ':']) do Dec(I);
  81. if (I > 0) and (FileName[I] = '.') then
  82. ExtractFileExt := Copy(FileName, I, 255)
  83. else ExtractFileExt := '';
  84. end;
  85. {
  86. $Log$
  87. Revision 1.1 1998-04-10 15:17:46 michael
  88. + Initial implementation; Donated by Gertjan Schouten
  89. His file was split into several files, to keep it a little bit structured.
  90. }