2
0

sysansi.inc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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;
  66. function BytesOf(const Val: RawByteString): TBytes;
  67. var
  68. Len:Integer;
  69. begin
  70. Len:=Length(Val);
  71. SetLength(Result,Len);
  72. if Len>0 then
  73. Move(Val[1],Result[0],Len);
  74. end;
  75. function BytesOf(const Val: AnsiChar): TBytes;
  76. begin
  77. SetLength(Result,1);
  78. Result[0]:=Byte(Val);
  79. end;
  80. Function CharInSet(Ch:AnsiChar;Const CSet : TSysCharSet) : Boolean; inline;
  81. begin
  82. result:=ch in CSet;
  83. end;