sysansi.inc 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. {
  2. *********************************************************************
  3. Copyright (C) 2002 by Florian Klaempfl
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  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. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. *********************************************************************
  16. }
  17. Function AnsiCompareFileName(const S1, S2: string): SizeInt;
  18. begin
  19. If FileNameCaseSensitive then
  20. Result:=AnsiCompareStr(S1,S2) // Compare case sensitive
  21. else
  22. Result:=AnsiCompareText(S1,S2); // Compare case insensitive. No MBCS yet.
  23. end;
  24. Function SameFileName(const S1, S2: string): Boolean;
  25. begin
  26. Result:=AnsiCompareFileName(S1,S2)=0;
  27. end;
  28. Function AnsiLowerCaseFileName(const S: string): string;
  29. begin
  30. Result:=AnsiLowerCase(S); // No locale support or MBCS yet.
  31. end;
  32. Function AnsiUpperCaseFileName(const S: string): string;
  33. begin
  34. Result:=AnsiUpperCase(S); // No locale support or MBCS yet.
  35. end;
  36. Function AnsiPos(const Substr, S: string): SizeInt;
  37. begin
  38. Result:=Pos(Substr,S); // No MBCS yet.
  39. end;
  40. Function AnsiStrPos(Str, SubStr: PChar): PChar;
  41. begin
  42. Result:=StrPos(Str,Substr);
  43. end;
  44. Function AnsiStrRScan(Str: PChar; Chr: Char): PChar;
  45. begin
  46. Result:=StrRScan(Str,Chr);
  47. end;
  48. Function AnsiStrScan(Str: PChar; Chr: Char): PChar;
  49. begin
  50. Result:=StrScan(Str,Chr);
  51. end;
  52. Function HashName(Name: PAnsiChar): LongWord;
  53. Var
  54. thehash,g,I : LongWord;
  55. begin
  56. thehash:=0;
  57. For I:=1 to Length(Name) do { 0 terminated }
  58. begin
  59. thehash:=thehash shl 4;
  60. inc(theHash,Ord(UpCase(Name[i])));
  61. g:=thehash and LongWord($f shl 28);
  62. if g<>0 then
  63. begin
  64. thehash:=thehash xor (g shr 24);
  65. thehash:=thehash xor g;
  66. end;
  67. end;
  68. If theHash=0 then
  69. HashName:=$ffffffff
  70. else
  71. HashName:=TheHash;
  72. end;
  73. function BytesOf(const Val: RawByteString): TBytes;
  74. var
  75. Len:Integer;
  76. begin
  77. Len:=Length(Val);
  78. SetLength(Result,Len);
  79. if Len>0 then
  80. Move(Val[1],Result[0],Len);
  81. end;
  82. function BytesOf(const Val: AnsiChar): TBytes;
  83. begin
  84. SetLength(Result,1);
  85. Result[0]:=Byte(Val);
  86. end;