sysansi.inc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 : LongWord;
  48. I : SizeInt;
  49. begin
  50. thehash:=0;
  51. For I:=0 to StrLen(Name)-1 do { 0 terminated }
  52. begin
  53. thehash:=thehash shl 4;
  54. inc(theHash,Ord(UpCase(Name[i])));
  55. g:=thehash and LongWord($f shl 28);
  56. if g<>0 then
  57. begin
  58. thehash:=thehash xor (g shr 24);
  59. thehash:=thehash xor g;
  60. end;
  61. end;
  62. If theHash=0 then
  63. HashName:=$ffffffff
  64. else
  65. HashName:=TheHash;
  66. end;
  67. function BytesOf(const Val: RawByteString): TBytes;
  68. var
  69. Len:Integer;
  70. begin
  71. Len:=Length(Val);
  72. SetLength(Result,Len);
  73. if Len>0 then
  74. Move(Val[1],Result[0],Len);
  75. end;
  76. function BytesOf(const Val: AnsiChar): TBytes;
  77. begin
  78. SetLength(Result,1);
  79. Result[0]:=Byte(Val);
  80. end;
  81. Function CharInSet(Ch:AnsiChar;Const CSet : TSysCharSet) : Boolean; inline;
  82. begin
  83. result:=ch in CSet;
  84. end;