sysansi.inc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. {
  2. *********************************************************************
  3. Copyright (C) 2002 by Florian Klaempfl
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. Function AnsiCompareFileName(const S1, S2: string): SizeInt;
  11. begin
  12. If FileNameCaseSensitive then
  13. Result:=AnsiCompareStr(S1,S2) // Compare case sensitive
  14. else
  15. Result:=AnsiCompareText(S1,S2); // Compare case insensitive. No MBCS yet.
  16. end;
  17. Function SameFileName(const S1, S2: string): Boolean;
  18. begin
  19. Result:=AnsiCompareFileName(S1,S2)=0;
  20. end;
  21. Function AnsiLowerCaseFileName(const S: string): string;
  22. begin
  23. Result:=AnsiLowerCase(S); // No locale support or MBCS yet.
  24. end;
  25. Function AnsiUpperCaseFileName(const S: string): string;
  26. begin
  27. Result:=AnsiUpperCase(S); // No locale support or MBCS yet.
  28. end;
  29. Function AnsiPos(const Substr, S: string): SizeInt;
  30. begin
  31. Result:=Pos(Substr,S); // No MBCS yet.
  32. end;
  33. Function AnsiStrPos(Str, SubStr: PChar): PChar;
  34. begin
  35. Result:=StrPos(Str,Substr);
  36. end;
  37. Function AnsiStrRScan(Str: PChar; Chr: Char): PChar;
  38. begin
  39. Result:=StrRScan(Str,Chr);
  40. end;
  41. Function AnsiStrScan(Str: PChar; Chr: Char): PChar;
  42. begin
  43. Result:=StrScan(Str,Chr);
  44. end;
  45. Function HashName(Name: PAnsiChar): LongWord;
  46. Var
  47. thehash,g,I : LongWord;
  48. begin
  49. thehash:=0;
  50. For I:=1 to Length(Name) do { 0 terminated }
  51. begin
  52. thehash:=thehash shl 4;
  53. inc(theHash,Ord(UpCase(Name[i])));
  54. g:=thehash and LongWord($f shl 28);
  55. if g<>0 then
  56. begin
  57. thehash:=thehash xor (g shr 24);
  58. thehash:=thehash xor g;
  59. end;
  60. end;
  61. If theHash=0 then
  62. HashName:=$ffffffff
  63. else
  64. HashName:=TheHash;
  65. end;