wutils.pas 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998 by Berczi Gabor
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. unit WUtils;
  12. interface
  13. {$ifndef FPC}
  14. {$define TPUNIXLF}
  15. {$endif}
  16. uses
  17. {$ifdef win32}
  18. windows,
  19. {$endif win32}
  20. {$ifdef Unix}
  21. {$ifdef VER1_0}
  22. linux,
  23. {$else}
  24. baseunix,
  25. unix,
  26. {$endif}
  27. {$endif Unix}
  28. Dos,Objects;
  29. const
  30. kbCtrlGrayPlus = $9000;
  31. kbCtrlGrayMinus = $8e00;
  32. kbCtrlGrayMul = $9600;
  33. TempFirstChar = {$ifndef Unix}'~'{$else}'_'{$endif};
  34. TempExt = '.tmp';
  35. TempNameLen = 8;
  36. EOL : String[2] = {$ifdef Unix}#10;{$else}#13#10;{$endif}
  37. type
  38. PByteArray = ^TByteArray;
  39. TByteArray = array[0..MaxBytes] of byte;
  40. PNoDisposeCollection = ^TNoDisposeCollection;
  41. TNoDisposeCollection = object(TCollection)
  42. procedure FreeItem(Item: Pointer); virtual;
  43. end;
  44. PUnsortedStringCollection = ^TUnsortedStringCollection;
  45. TUnsortedStringCollection = object(TCollection)
  46. constructor CreateFrom(ALines: PUnsortedStringCollection);
  47. procedure Assign(ALines: PUnsortedStringCollection);
  48. function At(Index: Sw_Integer): PString;
  49. procedure FreeItem(Item: Pointer); virtual;
  50. function GetItem(var S: TStream): Pointer; virtual;
  51. procedure PutItem(var S: TStream; Item: Pointer); virtual;
  52. procedure InsertStr(const S: string);
  53. end;
  54. PNulStream = ^TNulStream;
  55. TNulStream = object(TStream)
  56. constructor Init;
  57. function GetPos: Longint; virtual;
  58. function GetSize: Longint; virtual;
  59. procedure Read(var Buf; Count: Word); virtual;
  60. procedure Seek(Pos: Longint); virtual;
  61. procedure Write(var Buf; Count: Word); virtual;
  62. end;
  63. PSubStream = ^TSubStream;
  64. TSubStream = object(TStream)
  65. constructor Init(AStream: PStream; AStartPos, ASize: longint);
  66. function GetPos: Longint; virtual;
  67. function GetSize: Longint; virtual;
  68. procedure Read(var Buf; Count: Word); virtual;
  69. procedure Seek(Pos: Longint); virtual;
  70. procedure Write(var Buf; Count: Word); virtual;
  71. private
  72. StartPos: longint;
  73. S : PStream;
  74. end;
  75. PFastBufStream = ^TFastBufStream;
  76. TFastBufStream = object(TBufStream)
  77. constructor Init (FileName: FNameStr; Mode, Size: Word);
  78. procedure Seek(Pos: Longint); virtual;
  79. procedure Readline(var s:string;var linecomplete,hasCR : boolean);
  80. private
  81. BasePos: longint;
  82. end;
  83. PTextCollection = ^TTextCollection;
  84. TTextCollection = object(TStringCollection)
  85. function LookUp(const S: string; var Idx: sw_integer): string;
  86. function Compare(Key1, Key2: Pointer): sw_Integer; virtual;
  87. end;
  88. PIntCollection = ^TIntCollection;
  89. TIntCollection = object(TSortedCollection)
  90. function Compare(Key1, Key2: Pointer): sw_Integer; virtual;
  91. procedure FreeItem(Item: Pointer); virtual;
  92. procedure Add(Item: longint);
  93. function Contains(Item: longint): boolean;
  94. function AtInt(Index: sw_integer): longint;
  95. end;
  96. {$ifdef TPUNIXLF}
  97. procedure readln(var t:text;var s:string);
  98. {$endif}
  99. procedure ReadlnFromStream(Stream: PStream; var s:string;var linecomplete,hasCR : boolean);
  100. function eofstream(s: pstream): boolean;
  101. function Min(A,B: longint): longint;
  102. function Max(A,B: longint): longint;
  103. function CharStr(C: char; Count: integer): string;
  104. function UpcaseStr(const S: string): string;
  105. function LowCase(C: char): char;
  106. function LowcaseStr(S: string): string;
  107. function RExpand(const S: string; MinLen: byte): string;
  108. function LExpand(const S: string; MinLen: byte): string;
  109. function LTrim(const S: string): string;
  110. function RTrim(const S: string): string;
  111. function Trim(const S: string): string;
  112. function IntToStr(L: longint): string;
  113. function IntToStrL(L: longint; MinLen: sw_integer): string;
  114. function IntToStrZ(L: longint; MinLen: sw_integer): string;
  115. function StrToInt(const S: string): longint;
  116. function StrToCard(const S: string): cardinal;
  117. function FloatToStr(D: Double; Decimals: byte): string;
  118. function FloatToStrL(D: Double; Decimals: byte; MinLen: byte): string;
  119. function HexToInt(S: string): longint;
  120. function HexToCard(S: string): cardinal;
  121. function IntToHex(L: longint; MinLen: integer): string;
  122. function GetStr(P: PString): string;
  123. function GetPChar(P: PChar): string;
  124. function BoolToStr(B: boolean; const TrueS, FalseS: string): string;
  125. function LExtendString(S: string; MinLen: byte): string;
  126. function DirOf(const S: string): string;
  127. function ExtOf(const S: string): string;
  128. function NameOf(const S: string): string;
  129. function NameAndExtOf(const S: string): string;
  130. function DirAndNameOf(const S: string): string;
  131. { return Dos GetFTime value or -1 if the file does not exist }
  132. function GetFileTime(const FileName: string): longint;
  133. { copied from compiler global unit }
  134. function GetShortName(const n:string):string;
  135. function GetLongName(const n:string):string;
  136. function TrimEndSlash(const Path: string): string;
  137. function CompleteDir(const Path: string): string;
  138. function GetCurDir: string;
  139. function OptimizePath(Path: string; MaxLen: integer): string;
  140. function CompareText(S1, S2: string): integer;
  141. function ExistsDir(const DirName: string): boolean;
  142. function ExistsFile(const FileName: string): boolean;
  143. function SizeOfFile(const FileName: string): longint;
  144. function DeleteFile(const FileName: string): integer;
  145. function CopyFile(const SrcFileName, DestFileName: string): boolean;
  146. function GenTempFileName: string;
  147. function FormatPath(Path: string): string;
  148. function CompletePath(const Base, InComplete: string): string;
  149. function CompleteURL(const Base, URLRef: string): string;
  150. function EatIO: integer;
  151. function Now: longint;
  152. function FormatDateTimeL(L: longint; const Format: string): string;
  153. function FormatDateTime(const D: DateTime; const Format: string): string;
  154. {$ifdef TP}
  155. function StrPas(C: PChar): string;
  156. {$endif}
  157. function MemToStr(var B; Count: byte): string;
  158. procedure StrToMem(S: string; var B);
  159. procedure GiveUpTimeSlice;
  160. const LastStrToIntResult : integer = 0;
  161. LastHexToIntResult : integer = 0;
  162. LastStrToCardResult : integer = 0;
  163. LastHexToCardResult : integer = 0;
  164. DirSep : char = {$ifdef Unix}'/'{$else}'\'{$endif};
  165. UseOldBufStreamMethod : boolean = false;
  166. procedure RegisterWUtils;
  167. implementation
  168. uses
  169. {$IFDEF OS2}
  170. DosCalls,
  171. {$ENDIF OS2}
  172. Strings;
  173. {$ifndef NOOBJREG}
  174. const
  175. SpaceStr = ' '+
  176. ' '+
  177. ' '+
  178. ' ' ;
  179. RUnsortedStringCollection: TStreamRec = (
  180. ObjType: 22500;
  181. VmtLink: Ofs(TypeOf(TUnsortedStringCollection)^);
  182. Load: @TUnsortedStringCollection.Load;
  183. Store: @TUnsortedStringCollection.Store
  184. );
  185. {$endif}
  186. {$ifdef TPUNIXLF}
  187. procedure readln(var t:text;var s:string);
  188. var
  189. c : char;
  190. i : longint;
  191. begin
  192. if TextRec(t).UserData[1]=2 then
  193. system.readln(t,s)
  194. else
  195. begin
  196. c:=#0;
  197. i:=0;
  198. while (not eof(t)) and (c<>#10) and (i<High(S)) do
  199. begin
  200. read(t,c);
  201. if c<>#10 then
  202. begin
  203. inc(i);
  204. s[i]:=c;
  205. end;
  206. end;
  207. if (i>0) and (s[i]=#13) then
  208. begin
  209. dec(i);
  210. TextRec(t).UserData[1]:=2;
  211. end;
  212. s[0]:=chr(i);
  213. end;
  214. end;
  215. {$endif}
  216. function eofstream(s: pstream): boolean;
  217. begin
  218. eofstream:=(s^.getpos>=s^.getsize);
  219. end;
  220. procedure ReadlnFromStream(Stream: PStream; var S:string;var linecomplete,hasCR : boolean);
  221. var
  222. c : char;
  223. i,pos : longint;
  224. begin
  225. linecomplete:=false;
  226. c:=#0;
  227. i:=0;
  228. { this created problems for lines longer than 255 characters
  229. now those lines are cutted into pieces without warning PM }
  230. { changed implicit 255 to High(S), so it will be automatically extended
  231. when longstrings eventually become default - Gabor }
  232. while (not eofstream(stream)) and (c<>#10) and (i<High(S)) do
  233. begin
  234. stream^.read(c,sizeof(c));
  235. if c<>#10 then
  236. begin
  237. inc(i);
  238. s[i]:=c;
  239. end;
  240. end;
  241. { if there was a CR LF then remove the CR Dos newline style }
  242. if (i>0) and (s[i]=#13) then
  243. begin
  244. dec(i);
  245. end;
  246. if (c=#13) and (not eofstream(stream)) then
  247. stream^.read(c,sizeof(c));
  248. if (i=High(S)) and not eofstream(stream) then
  249. begin
  250. pos:=stream^.getpos;
  251. stream^.read(c,sizeof(c));
  252. if (c=#13) and not eofstream(stream) then
  253. stream^.read(c,sizeof(c));
  254. if c<>#10 then
  255. stream^.seek(pos);
  256. end;
  257. if (c=#10) or eofstream(stream) then
  258. linecomplete:=true;
  259. if (c=#10) then
  260. hasCR:=true;
  261. s[0]:=chr(i);
  262. end;
  263. {$ifdef TP}
  264. { TP's own StrPas() is buggy, because it causes GPF with strings longer than
  265. 255 chars }
  266. function StrPas(C: PChar): string;
  267. var S: string;
  268. I: longint;
  269. begin
  270. if Assigned(C)=false then
  271. S:=''
  272. else
  273. begin
  274. I:=StrLen(C); if I>High(S) then I:=High(S);
  275. S[0]:=chr(I); Move(C^,S[1],I);
  276. end;
  277. StrPas:=S;
  278. end;
  279. {$endif}
  280. function MemToStr(var B; Count: byte): string;
  281. var S: string;
  282. begin
  283. S[0]:=chr(Count);
  284. if Count>0 then Move(B,S[1],Count);
  285. MemToStr:=S;
  286. end;
  287. procedure StrToMem(S: string; var B);
  288. begin
  289. if length(S)>0 then Move(S[1],B,length(S));
  290. end;
  291. function Max(A,B: longint): longint;
  292. begin
  293. if A>B then Max:=A else Max:=B;
  294. end;
  295. function Min(A,B: longint): longint;
  296. begin
  297. if A<B then Min:=A else Min:=B;
  298. end;
  299. function CharStr(C: char; Count: integer): string;
  300. {$ifndef FPC}
  301. var S: string;
  302. {$endif}
  303. begin
  304. if Count<=0 then
  305. begin
  306. CharStr:='';
  307. exit;
  308. end
  309. else if Count>255 then
  310. Count:=255;
  311. {$ifdef FPC}
  312. CharStr[0]:=chr(Count);
  313. FillChar(CharStr[1],Count,C);
  314. {$else}
  315. S[0]:=chr(Count);
  316. FillChar(S[1],Count,C);
  317. CharStr:=S;
  318. {$endif}
  319. end;
  320. function UpcaseStr(const S: string): string;
  321. var
  322. I: Longint;
  323. begin
  324. for I:=1 to length(S) do
  325. if S[I] in ['a'..'z'] then
  326. UpCaseStr[I]:=chr(ord(S[I])-32)
  327. else
  328. UpCaseStr[I]:=S[I];
  329. UpcaseStr[0]:=S[0];
  330. end;
  331. function RExpand(const S: string; MinLen: byte): string;
  332. begin
  333. if length(S)<MinLen then
  334. RExpand:=S+CharStr(' ',MinLen-length(S))
  335. else
  336. RExpand:=S;
  337. end;
  338. function LExpand(const S: string; MinLen: byte): string;
  339. begin
  340. if length(S)<MinLen then
  341. LExpand:=CharStr(' ',MinLen-length(S))+S
  342. else
  343. LExpand:=S;
  344. end;
  345. function LTrim(const S: string): string;
  346. var
  347. i : longint;
  348. begin
  349. i:=1;
  350. while (i<length(s)) and (s[i]=' ') do
  351. inc(i);
  352. LTrim:=Copy(s,i,High(S));
  353. end;
  354. function RTrim(const S: string): string;
  355. var
  356. i : longint;
  357. begin
  358. i:=length(s);
  359. while (i>0) and (s[i]=' ') do
  360. dec(i);
  361. RTrim:=Copy(s,1,i);
  362. end;
  363. function Trim(const S: string): string;
  364. var
  365. i,j : longint;
  366. begin
  367. i:=1;
  368. while (i<length(s)) and (s[i]=' ') do
  369. inc(i);
  370. j:=length(s);
  371. while (j>0) and (s[j]=' ') do
  372. dec(j);
  373. Trim:=Copy(S,i,j-i+1);
  374. end;
  375. function IntToStr(L: longint): string;
  376. var S: string;
  377. begin
  378. Str(L,S);
  379. IntToStr:=S;
  380. end;
  381. function IntToStrL(L: longint; MinLen: sw_integer): string;
  382. begin
  383. IntToStrL:=LExpand(IntToStr(L),MinLen);
  384. end;
  385. function IntToStrZ(L: longint; MinLen: sw_integer): string;
  386. var S: string;
  387. begin
  388. S:=IntToStr(L);
  389. if length(S)<MinLen then
  390. S:=CharStr('0',MinLen-length(S))+S;
  391. IntToStrZ:=S;
  392. end;
  393. function StrToInt(const S: string): longint;
  394. var L: longint;
  395. C: integer;
  396. begin
  397. Val(S,L,C); if C<>0 then L:=-1;
  398. LastStrToIntResult:=C;
  399. StrToInt:=L;
  400. end;
  401. function StrToCard(const S: string): cardinal;
  402. var L: cardinal;
  403. C: integer;
  404. begin
  405. Val(S,L,C); if C<>0 then L:=$ffffffff;
  406. LastStrToCardResult:=C;
  407. StrToCard:=L;
  408. end;
  409. function HexToInt(S: string): longint;
  410. var L,I: longint;
  411. C: char;
  412. const HexNums: string[16] = '0123456789ABCDEF';
  413. begin
  414. S:=Trim(S); L:=0; I:=1; LastHexToIntResult:=0;
  415. while (I<=length(S)) and (LastHexToIntResult=0) do
  416. begin
  417. C:=Upcase(S[I]);
  418. if C in['0'..'9','A'..'F'] then
  419. begin
  420. L:=L*16+(Pos(C,HexNums)-1);
  421. end else LastHexToIntResult:=I;
  422. Inc(I);
  423. end;
  424. HexToInt:=L;
  425. end;
  426. function HexToCard(S: string): cardinal;
  427. var L,I: cardinal;
  428. C: char;
  429. const HexNums: string[16] = '0123456789ABCDEF';
  430. begin
  431. S:=Trim(S); L:=0; I:=1; LastHexToCardResult:=0;
  432. while (I<=length(S)) and (LastHexToCardResult=0) do
  433. begin
  434. C:=Upcase(S[I]);
  435. if C in['0'..'9','A'..'F'] then
  436. begin
  437. L:=L*16+(Pos(C,HexNums)-1);
  438. end else LastHexToCardResult:=I;
  439. Inc(I);
  440. end;
  441. HexToCard:=L;
  442. end;
  443. function IntToHex(L: longint; MinLen: integer): string;
  444. const HexNums : string[16] = '0123456789ABCDEF';
  445. var S: string;
  446. R: real;
  447. function DivF(Mit,Mivel: real): longint;
  448. begin
  449. DivF:=trunc(Mit/Mivel);
  450. end;
  451. function ModF(Mit,Mivel: real): longint;
  452. begin
  453. ModF:=trunc(Mit-DivF(Mit,Mivel)*Mivel);
  454. end;
  455. begin
  456. S:='';
  457. R:=L; if R<0 then begin R:=R+2147483647+2147483647+2; end;
  458. repeat
  459. Insert(HexNums[ModF(R,16)+1],S,1);
  460. R:=DivF(R,16);
  461. until R=0;
  462. while length(S)<MinLen do
  463. Insert('0',S,1);
  464. IntToHex:=S;
  465. end;
  466. function FloatToStr(D: Double; Decimals: byte): string;
  467. var S: string;
  468. L: byte;
  469. begin
  470. Str(D:0:Decimals,S);
  471. if length(S)>0 then
  472. while (S[1]=' ') do Delete(S,1,1);
  473. FloatToStr:=S;
  474. end;
  475. function FloatToStrL(D: Double; Decimals: byte; MinLen: byte): string;
  476. begin
  477. FloatToStrL:=LExtendString(FloatToStr(D,Decimals),MinLen);
  478. end;
  479. function LExtendString(S: string; MinLen: byte): string;
  480. begin
  481. LExtendString:=copy(SpaceStr,1,MinLen-length(S))+S;
  482. end;
  483. function GetStr(P: PString): string;
  484. begin
  485. if P=nil then GetStr:='' else GetStr:=P^;
  486. end;
  487. function GetPChar(P: PChar): string;
  488. begin
  489. if P=nil then GetPChar:='' else GetPChar:=StrPas(P);
  490. end;
  491. function DirOf(const S: string): string;
  492. var D: DirStr; E: ExtStr; N: NameStr;
  493. begin
  494. FSplit(S,D,N,E);
  495. if (D<>'') and (D[Length(D)]<>DirSep) then
  496. DirOf:=D+DirSep
  497. else
  498. DirOf:=D;
  499. end;
  500. function ExtOf(const S: string): string;
  501. var D: DirStr; E: ExtStr; N: NameStr;
  502. begin
  503. FSplit(S,D,N,E);
  504. ExtOf:=E;
  505. end;
  506. function NameOf(const S: string): string;
  507. var D: DirStr; E: ExtStr; N: NameStr;
  508. begin
  509. FSplit(S,D,N,E);
  510. NameOf:=N;
  511. end;
  512. function NameAndExtOf(const S: string): string;
  513. var D: DirStr; E: ExtStr; N: NameStr;
  514. begin
  515. FSplit(S,D,N,E);
  516. NameAndExtOf:=N+E;
  517. end;
  518. function DirAndNameOf(const S: string): string;
  519. var D: DirStr; E: ExtStr; N: NameStr;
  520. begin
  521. FSplit(S,D,N,E);
  522. DirAndNameOf:=D+N;
  523. end;
  524. { return Dos GetFTime value or -1 if the file does not exist }
  525. function GetFileTime(const FileName: string): longint;
  526. var T: longint;
  527. f: file;
  528. FM: integer;
  529. begin
  530. if FileName='' then
  531. T:=-1
  532. else
  533. begin
  534. FM:=FileMode; FileMode:=0;
  535. EatIO; Dos.DosError:=0;
  536. Assign(f,FileName);
  537. {$I-}
  538. Reset(f);
  539. if InOutRes=0 then
  540. begin
  541. GetFTime(f,T);
  542. Close(f);
  543. end;
  544. {$I+}
  545. if (EatIO<>0) or (Dos.DosError<>0) then T:=-1;
  546. FileMode:=FM;
  547. end;
  548. GetFileTime:=T;
  549. end;
  550. function GetShortName(const n:string):string;
  551. {$ifdef win32}
  552. var
  553. hs,hs2 : string;
  554. i : longint;
  555. {$endif}
  556. {$ifdef go32v2}
  557. var
  558. hs : string;
  559. {$endif}
  560. begin
  561. GetShortName:=n;
  562. {$ifdef win32}
  563. hs:=n+#0;
  564. i:=Windows.GetShortPathName(@hs[1],@hs2[1],high(hs2));
  565. if (i>0) and (i<=high(hs2)) then
  566. begin
  567. hs2[0]:=chr(strlen(@hs2[1]));
  568. GetShortName:=hs2;
  569. end;
  570. {$endif}
  571. {$ifdef go32v2}
  572. hs:=n;
  573. if Dos.GetShortName(hs) then
  574. GetShortName:=hs;
  575. {$endif}
  576. end;
  577. function GetLongName(const n:string):string;
  578. {$ifdef win32}
  579. var
  580. hs : string;
  581. hs2 : Array [0..255] of char;
  582. i : longint;
  583. j : pchar;
  584. {$endif}
  585. {$ifdef go32v2}
  586. var
  587. hs : string;
  588. {$endif}
  589. begin
  590. GetLongName:=n;
  591. {$ifdef win32}
  592. hs:=n+#0;
  593. i:=Windows.GetFullPathName(@hs[1],256,hs2,j);
  594. if (i>0) and (i<=high(hs)) then
  595. begin
  596. hs:=strpas(hs2);
  597. GetLongName:=hs;
  598. end;
  599. {$endif}
  600. {$ifdef go32v2}
  601. hs:=n;
  602. if Dos.GetLongName(hs) then
  603. GetLongName:=hs;
  604. {$endif}
  605. end;
  606. function EatIO: integer;
  607. begin
  608. EatIO:=IOResult;
  609. end;
  610. function LowCase(C: char): char;
  611. begin
  612. if ('A'<=C) and (C<='Z') then C:=chr(ord(C)+32);
  613. LowCase:=C;
  614. end;
  615. function LowcaseStr(S: string): string;
  616. var I: Longint;
  617. begin
  618. for I:=1 to length(S) do
  619. S[I]:=Lowcase(S[I]);
  620. LowcaseStr:=S;
  621. end;
  622. function BoolToStr(B: boolean; const TrueS, FalseS: string): string;
  623. begin
  624. if B then BoolToStr:=TrueS else BoolToStr:=FalseS;
  625. end;
  626. procedure TNoDisposeCollection.FreeItem(Item: Pointer);
  627. begin
  628. { don't do anything here }
  629. end;
  630. constructor TUnsortedStringCollection.CreateFrom(ALines: PUnsortedStringCollection);
  631. begin
  632. if Assigned(ALines)=false then Fail;
  633. inherited Init(ALines^.Count,ALines^.Count div 10);
  634. Assign(ALines);
  635. end;
  636. procedure TUnsortedStringCollection.Assign(ALines: PUnsortedStringCollection);
  637. procedure AddIt(P: PString); {$ifndef FPC}far;{$endif}
  638. begin
  639. Insert(NewStr(GetStr(P)));
  640. end;
  641. begin
  642. FreeAll;
  643. if Assigned(ALines) then
  644. ALines^.ForEach(@AddIt);
  645. end;
  646. procedure TUnsortedStringCollection.InsertStr(const S: string);
  647. begin
  648. Insert(NewStr(S));
  649. end;
  650. function TUnsortedStringCollection.At(Index: Sw_Integer): PString;
  651. begin
  652. At:=inherited At(Index);
  653. end;
  654. procedure TUnsortedStringCollection.FreeItem(Item: Pointer);
  655. begin
  656. if Item<>nil then DisposeStr(Item);
  657. end;
  658. function TUnsortedStringCollection.GetItem(var S: TStream): Pointer;
  659. begin
  660. GetItem:=S.ReadStr;
  661. end;
  662. procedure TUnsortedStringCollection.PutItem(var S: TStream; Item: Pointer);
  663. begin
  664. S.WriteStr(Item);
  665. end;
  666. function TIntCollection.Contains(Item: longint): boolean;
  667. var Index: sw_integer;
  668. begin
  669. Contains:=Search(pointer(Item),Index);
  670. end;
  671. function TIntCollection.AtInt(Index: sw_integer): longint;
  672. begin
  673. AtInt:=longint(At(Index));
  674. end;
  675. procedure TIntCollection.Add(Item: longint);
  676. begin
  677. Insert(pointer(Item));
  678. end;
  679. function TIntCollection.Compare(Key1, Key2: Pointer): sw_Integer;
  680. var K1: longint absolute Key1;
  681. K2: longint absolute Key2;
  682. R: integer;
  683. begin
  684. if K1<K2 then R:=-1 else
  685. if K1>K2 then R:= 1 else
  686. R:=0;
  687. Compare:=R;
  688. end;
  689. procedure TIntCollection.FreeItem(Item: Pointer);
  690. begin
  691. { do nothing here }
  692. end;
  693. constructor TNulStream.Init;
  694. begin
  695. inherited Init;
  696. Position:=0;
  697. end;
  698. function TNulStream.GetPos: Longint;
  699. begin
  700. GetPos:=Position;
  701. end;
  702. function TNulStream.GetSize: Longint;
  703. begin
  704. GetSize:=Position;
  705. end;
  706. procedure TNulStream.Read(var Buf; Count: Word);
  707. begin
  708. Error(stReadError,0);
  709. end;
  710. procedure TNulStream.Seek(Pos: Longint);
  711. begin
  712. if Pos<=Position then
  713. Position:=Pos;
  714. end;
  715. procedure TNulStream.Write(var Buf; Count: Word);
  716. begin
  717. Inc(Position,Count);
  718. end;
  719. constructor TSubStream.Init(AStream: PStream; AStartPos, ASize: longint);
  720. begin
  721. inherited Init;
  722. if Assigned(AStream)=false then Fail;
  723. S:=AStream; StartPos:=AStartPos; StreamSize:=ASize;
  724. Seek(0);
  725. end;
  726. function TSubStream.GetPos: Longint;
  727. var Pos: longint;
  728. begin
  729. Pos:=S^.GetPos; Dec(Pos,StartPos);
  730. GetPos:=Pos;
  731. end;
  732. function TSubStream.GetSize: Longint;
  733. begin
  734. GetSize:=StreamSize;
  735. end;
  736. procedure TSubStream.Read(var Buf; Count: Word);
  737. var Pos: longint;
  738. RCount: word;
  739. begin
  740. Pos:=GetPos;
  741. if Pos+Count>StreamSize then RCount:=StreamSize-Pos else RCount:=Count;
  742. S^.Read(Buf,RCount);
  743. if RCount<Count then
  744. Error(stReadError,0);
  745. end;
  746. procedure TSubStream.Seek(Pos: Longint);
  747. var RPos: longint;
  748. begin
  749. if (Pos<=StreamSize) then RPos:=Pos else RPos:=StreamSize;
  750. S^.Seek(StartPos+RPos);
  751. end;
  752. procedure TSubStream.Write(var Buf; Count: Word);
  753. begin
  754. S^.Write(Buf,Count);
  755. end;
  756. constructor TFastBufStream.Init (FileName: FNameStr; Mode, Size: Word);
  757. begin
  758. Inherited Init(FileName,Mode,Size);
  759. BasePos:=0;
  760. end;
  761. procedure TFastBufStream.Seek(Pos: Longint);
  762. var RelOfs: longint;
  763. begin
  764. RelOfs:=Pos-BasePos;
  765. if (RelOfs<0) or (RelOfs>=BufEnd) or (BufEnd=0) then
  766. begin
  767. inherited Seek(Pos);
  768. BasePos:=Pos-BufPtr;
  769. end
  770. else
  771. begin
  772. BufPtr:=RelOfs;
  773. Position:=Pos;
  774. end;
  775. end;
  776. procedure TFastBufStream.Readline(var s:string;var linecomplete,hasCR : boolean);
  777. var
  778. c : char;
  779. i,pos,StartPos : longint;
  780. charsInS : boolean;
  781. begin
  782. linecomplete:=false;
  783. c:=#0;
  784. i:=0;
  785. { this created problems for lines longer than 255 characters
  786. now those lines are cutted into pieces without warning PM }
  787. { changed implicit 255 to High(S), so it will be automatically extended
  788. when longstrings eventually become default - Gabor }
  789. if (bufend-bufptr>=High(S)) and (getpos+High(S)<getsize) then
  790. begin
  791. StartPos:=GetPos;
  792. //read(S[1],High(S));
  793. system.move(buffer^[bufptr],S[1],High(S));
  794. charsInS:=true;
  795. end
  796. else
  797. CharsInS:=false;
  798. while (CharsInS or not (getpos>=getsize)) and
  799. (c<>#10) and (i<High(S)) do
  800. begin
  801. if CharsInS then
  802. c:=s[i+1]
  803. else
  804. read(c,sizeof(c));
  805. if c<>#10 then
  806. begin
  807. inc(i);
  808. if not CharsInS then
  809. s[i]:=c;
  810. end;
  811. end;
  812. if CharsInS then
  813. begin
  814. if c=#10 then
  815. Seek(StartPos+i+1)
  816. else
  817. Seek(StartPos+i);
  818. end;
  819. { if there was a CR LF then remove the CR Dos newline style }
  820. if (i>0) and (s[i]=#13) then
  821. begin
  822. dec(i);
  823. end;
  824. if (c=#13) and (not (getpos>=getsize)) then
  825. begin
  826. read(c,sizeof(c));
  827. end;
  828. if (i=High(S)) and not (getpos>=getsize) then
  829. begin
  830. pos:=getpos;
  831. read(c,sizeof(c));
  832. if (c=#13) and not (getpos>=getsize) then
  833. read(c,sizeof(c));
  834. if c<>#10 then
  835. seek(pos);
  836. end;
  837. if (c=#10) or (getpos>=getsize) then
  838. linecomplete:=true;
  839. if (c=#10) then
  840. hasCR:=true;
  841. s[0]:=chr(i);
  842. end;
  843. function TTextCollection.Compare(Key1, Key2: Pointer): Sw_Integer;
  844. var K1: PString absolute Key1;
  845. K2: PString absolute Key2;
  846. R: Sw_integer;
  847. S1,S2: string;
  848. begin
  849. S1:=UpCaseStr(K1^);
  850. S2:=UpCaseStr(K2^);
  851. if S1<S2 then R:=-1 else
  852. if S1>S2 then R:=1 else
  853. R:=0;
  854. Compare:=R;
  855. end;
  856. function TTextCollection.LookUp(const S: string; var Idx: sw_integer): string;
  857. var OLI,ORI,Left,Right,Mid: integer;
  858. {LeftP,RightP,}MidP: PString;
  859. {LeftS,}MidS{,RightS}: string;
  860. FoundS: string;
  861. UpS : string;
  862. begin
  863. Idx:=-1; FoundS:='';
  864. Left:=0; Right:=Count-1;
  865. UpS:=UpCaseStr(S);
  866. while Left<=Right do
  867. begin
  868. OLI:=Left; ORI:=Right;
  869. Mid:=Left+(Right-Left) div 2;
  870. MidP:=At(Mid);
  871. MidS:=UpCaseStr(MidP^);
  872. if copy(MidS,1,length(UpS))=UpS then
  873. begin
  874. Idx:=Mid; FoundS:=GetStr(MidP);
  875. { exit immediately if exact match PM }
  876. If Length(MidS)=Length(UpS) then
  877. break;
  878. end;
  879. if UpS<MidS then
  880. Right:=Mid
  881. else
  882. Left:=Mid;
  883. if (OLI=Left) and (ORI=Right) then
  884. begin
  885. if (Left<Right) then
  886. Left:=Right
  887. else
  888. Break;
  889. end;
  890. end;
  891. LookUp:=FoundS;
  892. end;
  893. function TrimEndSlash(const Path: string): string;
  894. var S: string;
  895. begin
  896. S:=Path;
  897. if (length(S)>0) and (S<>DirSep) and (copy(S,length(S),1)=DirSep) and
  898. (S[length(S)-1]<>':') then
  899. S:=copy(S,1,length(S)-1);
  900. TrimEndSlash:=S;
  901. end;
  902. function CompareText(S1, S2: string): integer;
  903. var R: integer;
  904. begin
  905. S1:=UpcaseStr(S1); S2:=UpcaseStr(S2);
  906. if S1<S2 then R:=-1 else
  907. if S1>S2 then R:= 1 else
  908. R:=0;
  909. CompareText:=R;
  910. end;
  911. function FormatPath(Path: string): string;
  912. var P: sw_integer;
  913. SC: char;
  914. begin
  915. if ord(DirSep)=ord('/') then
  916. SC:='\'
  917. else
  918. SC:='/';
  919. repeat
  920. P:=Pos(SC,Path);
  921. if P>0 then Path[P]:=DirSep;
  922. until P=0;
  923. FormatPath:=Path;
  924. end;
  925. function CompletePath(const Base, InComplete: string): string;
  926. var Drv,BDrv: string[40]; D,BD: DirStr; N,BN: NameStr; E,BE: ExtStr;
  927. P: sw_integer;
  928. Complete: string;
  929. begin
  930. Complete:=FormatPath(InComplete);
  931. FSplit(FormatPath(InComplete),D,N,E);
  932. P:=Pos(':',D); if P=0 then Drv:='' else begin Drv:=copy(D,1,P); Delete(D,1,P); end;
  933. FSplit(FormatPath(Base),BD,BN,BE);
  934. P:=Pos(':',BD); if P=0 then BDrv:='' else begin BDrv:=copy(BD,1,P); Delete(BD,1,P); end;
  935. if copy(D,1,1)<>DirSep then
  936. Complete:=BD+D+N+E;
  937. if Drv='' then
  938. Complete:=BDrv+Complete;
  939. Complete:=FExpand(Complete);
  940. CompletePath:=Complete;
  941. end;
  942. function CompleteURL(const Base, URLRef: string): string;
  943. var P: integer;
  944. Drive: string[20];
  945. IsComplete: boolean;
  946. S: string;
  947. Ref: string;
  948. Bookmark: string;
  949. begin
  950. IsComplete:=false; Ref:=URLRef;
  951. P:=Pos(':',Ref);
  952. if P=0 then Drive:='' else Drive:=UpcaseStr(copy(Ref,1,P-1));
  953. if Drive<>'' then
  954. if (Drive='MAILTO') or (Drive='FTP') or (Drive='HTTP') or
  955. (Drive='GOPHER') or (Drive='FILE') then
  956. IsComplete:=true;
  957. if IsComplete then S:=Ref else
  958. begin
  959. P:=Pos('#',Ref);
  960. if P=0 then
  961. Bookmark:=''
  962. else
  963. begin
  964. Bookmark:=copy(Ref,P+1,length(Ref));
  965. Ref:=copy(Ref,1,P-1);
  966. end;
  967. S:=CompletePath(Base,Ref);
  968. if Bookmark<>'' then
  969. S:=S+'#'+Bookmark;
  970. end;
  971. CompleteURL:=S;
  972. end;
  973. function OptimizePath(Path: string; MaxLen: integer): string;
  974. var i : integer;
  975. BackSlashs : array[1..20] of integer;
  976. BSCount : integer;
  977. Jobbra : boolean;
  978. Jobb, Bal : byte;
  979. Hiba : boolean;
  980. begin
  981. if length(Path)>MaxLen then
  982. begin
  983. BSCount:=0; Jobbra:=true;
  984. for i:=1 to length(Path) do if Path[i]=DirSep then
  985. begin
  986. Inc(BSCount);
  987. BackSlashs[BSCount]:=i;
  988. end;
  989. i:=BSCount div 2;
  990. Hiba:=false;
  991. Bal:=i; Jobb:=i+1;
  992. case i of 0 : ;
  993. 1 : Path:=copy(Path, 1, BackSlashs[1])+'..'+
  994. copy(Path, BackSlashs[2], length(Path));
  995. else begin
  996. while (BackSlashs[Bal]+(length(Path)-BackSlashs[Jobb]) >=
  997. MaxLen) and not Hiba do
  998. begin
  999. if Jobbra then begin
  1000. if Jobb<BSCount then inc(Jobb)
  1001. else Hiba:=true;
  1002. Jobbra:=false;
  1003. end
  1004. else begin
  1005. if Bal>1 then dec(Bal)
  1006. else Hiba:=true;
  1007. Jobbra:=true;
  1008. end;
  1009. end;
  1010. Path:=copy(Path, 1, BackSlashs[Bal])+'..'+
  1011. copy(Path, BackSlashs[Jobb], length(Path));
  1012. end;
  1013. end;
  1014. end;
  1015. if length(Path)>MaxLen then
  1016. begin
  1017. i:=Pos('\..\',Path);
  1018. if i>0 then Path:=copy(Path,1,i-1)+'..'+copy(Path,i+length('\..\'),length(Path));
  1019. end;
  1020. OptimizePath:=Path;
  1021. end;
  1022. function Now: longint;
  1023. var D: DateTime;
  1024. W: word;
  1025. L: longint;
  1026. begin
  1027. FillChar(D,sizeof(D),0);
  1028. GetDate(D.Year,D.Month,D.Day,W);
  1029. GetTime(D.Hour,D.Min,D.Sec,W);
  1030. PackTime(D,L);
  1031. Now:=L;
  1032. end;
  1033. function FormatDateTimeL(L: longint; const Format: string): string;
  1034. var D: DateTime;
  1035. begin
  1036. UnpackTime(L,D);
  1037. FormatDateTimeL:=FormatDateTime(D,Format);
  1038. end;
  1039. function FormatDateTime(const D: DateTime; const Format: string): string;
  1040. var I: sw_integer;
  1041. CurCharStart: sw_integer;
  1042. CurChar: char;
  1043. CurCharCount: integer;
  1044. DateS: string;
  1045. C: char;
  1046. procedure FlushChars;
  1047. var S: string;
  1048. I: sw_integer;
  1049. begin
  1050. S:='';
  1051. for I:=1 to CurCharCount do
  1052. S:=S+CurChar;
  1053. case CurChar of
  1054. 'y' : S:=IntToStrL(D.Year,length(S));
  1055. 'm' : S:=IntToStrZ(D.Month,length(S));
  1056. 'd' : S:=IntToStrZ(D.Day,length(S));
  1057. 'h' : S:=IntToStrZ(D.Hour,length(S));
  1058. 'n' : S:=IntToStrZ(D.Min,length(S));
  1059. 's' : S:=IntToStrZ(D.Sec,length(S));
  1060. end;
  1061. DateS:=DateS+S;
  1062. end;
  1063. begin
  1064. DateS:='';
  1065. CurCharStart:=-1; CurCharCount:=0; CurChar:=#0;
  1066. for I:=1 to length(Format) do
  1067. begin
  1068. C:=Format[I];
  1069. if (C<>CurChar) or (CurCharStart=-1) then
  1070. begin
  1071. if CurCharStart<>-1 then FlushChars;
  1072. CurCharCount:=1; CurCharStart:=I;
  1073. end
  1074. else
  1075. Inc(CurCharCount);
  1076. CurChar:=C;
  1077. end;
  1078. FlushChars;
  1079. FormatDateTime:=DateS;
  1080. end;
  1081. function DeleteFile(const FileName: string): integer;
  1082. var f: file;
  1083. begin
  1084. {$I-}
  1085. Assign(f,FileName);
  1086. Erase(f);
  1087. DeleteFile:=EatIO;
  1088. {$I+}
  1089. end;
  1090. function ExistsFile(const FileName: string): boolean;
  1091. var
  1092. Dir : SearchRec;
  1093. begin
  1094. Dos.FindFirst(FileName,Archive+ReadOnly,Dir);
  1095. ExistsFile:=(Dos.DosError=0);
  1096. {$ifdef FPC}
  1097. Dos.FindClose(Dir);
  1098. {$endif def FPC}
  1099. end;
  1100. { returns zero for empty and non existant files }
  1101. function SizeOfFile(const FileName: string): longint;
  1102. var
  1103. Dir : SearchRec;
  1104. begin
  1105. Dos.FindFirst(FileName,Archive+ReadOnly,Dir);
  1106. if (Dos.DosError=0) then
  1107. SizeOfFile:=Dir.Size
  1108. else
  1109. SizeOfFile:=0;
  1110. {$ifdef FPC}
  1111. Dos.FindClose(Dir);
  1112. {$endif def FPC}
  1113. end;
  1114. function ExistsDir(const DirName: string): boolean;
  1115. var
  1116. Dir : SearchRec;
  1117. begin
  1118. Dos.FindFirst(TrimEndSlash(DirName),Directory,Dir);
  1119. { if a file is found it is also reported
  1120. at least for some Dos version
  1121. so we need to check the attributes PM }
  1122. ExistsDir:=(Dos.DosError=0) and ((Dir.attr and Directory) <> 0);
  1123. {$ifdef FPC}
  1124. Dos.FindClose(Dir);
  1125. {$endif def FPC}
  1126. end;
  1127. function CompleteDir(const Path: string): string;
  1128. begin
  1129. { keep c: untouched PM }
  1130. if (Path<>'') and (Path[Length(Path)]<>DirSep) and
  1131. (Path[Length(Path)]<>':') then
  1132. CompleteDir:=Path+DirSep
  1133. else
  1134. CompleteDir:=Path;
  1135. end;
  1136. function GetCurDir: string;
  1137. var S: string;
  1138. begin
  1139. GetDir(0,S);
  1140. if copy(S,length(S),1)<>DirSep then S:=S+DirSep;
  1141. GetCurDir:=S;
  1142. end;
  1143. function GenTempFileName: string;
  1144. var Dir: string;
  1145. Name: string;
  1146. I: integer;
  1147. OK: boolean;
  1148. Path: string;
  1149. begin
  1150. Dir:=GetEnv('TEMP');
  1151. if Dir='' then Dir:=GetEnv('TMP');
  1152. if (Dir<>'') then if not ExistsDir(Dir) then Dir:='';
  1153. if Dir='' then Dir:=GetCurDir;
  1154. repeat
  1155. Name:=TempFirstChar;
  1156. for I:=2 to TempNameLen do
  1157. Name:=Name+chr(ord('a')+random(ord('z')-ord('a')+1));
  1158. Name:=Name+TempExt;
  1159. Path:=CompleteDir(Dir)+Name;
  1160. OK:=not ExistsFile(Path);
  1161. until OK;
  1162. GenTempFileName:=Path;
  1163. end;
  1164. function CopyFile(const SrcFileName, DestFileName: string): boolean;
  1165. var SrcF,DestF: PBufStream;
  1166. OK: boolean;
  1167. begin
  1168. SrcF:=nil; DestF:=nil;
  1169. New(SrcF, Init(SrcFileName,stOpenRead,4096));
  1170. OK:=Assigned(SrcF) and (SrcF^.Status=stOK);
  1171. if OK then
  1172. begin
  1173. New(DestF, Init(DestFileName,stCreate,1024));
  1174. OK:=Assigned(DestF) and (DestF^.Status=stOK);
  1175. end;
  1176. if OK then DestF^.CopyFrom(SrcF^,SrcF^.GetSize);
  1177. if Assigned(DestF) then Dispose(DestF, Done);
  1178. if Assigned(SrcF) then Dispose(SrcF, Done);
  1179. CopyFile:=OK;
  1180. end;
  1181. procedure GiveUpTimeSlice;
  1182. {$ifdef GO32V2}{$define DOS}{$endif}
  1183. {$ifdef TP}{$define DOS}{$endif}
  1184. {$ifdef DOS}
  1185. var r: registers;
  1186. begin
  1187. r.ax:=$1680;
  1188. intr($2f,r);
  1189. end;
  1190. {$endif}
  1191. {$ifdef Unix}
  1192. var
  1193. req,rem : timespec;
  1194. begin
  1195. req.tv_sec:=0;
  1196. req.tv_nsec:=10000000;{ 10 ms }
  1197. {$ifdef ver1_0}nanosleep(req,rem){$else}fpnanosleep(@req,@rem){$endif};
  1198. end;
  1199. {$endif}
  1200. {$IFDEF OS2}
  1201. begin
  1202. DosSleep (5);
  1203. end;
  1204. {$ENDIF}
  1205. {$ifdef Win32}
  1206. begin
  1207. { if the return value of this call is non zero then
  1208. it means that a ReadFileEx or WriteFileEx have completed
  1209. unused for now ! }
  1210. { wait for 10 ms }
  1211. if SleepEx(10,true)=WAIT_IO_COMPLETION then
  1212. begin
  1213. { here we should handle the completion of the routines
  1214. if we use them }
  1215. end;
  1216. end;
  1217. {$endif}
  1218. {$undef DOS}
  1219. procedure RegisterWUtils;
  1220. begin
  1221. {$ifndef NOOBJREG}
  1222. RegisterType(RUnsortedStringCollection);
  1223. {$endif}
  1224. end;
  1225. BEGIN
  1226. Randomize;
  1227. END.
  1228. {
  1229. $Log$
  1230. Revision 1.17 2003-09-27 14:03:45 peter
  1231. * fixed for unix
  1232. Revision 1.16 2002/09/11 12:10:03 pierre
  1233. * fix bug in new readline method on line overflow
  1234. Revision 1.15 2002/09/11 08:30:38 pierre
  1235. * avoid a lot of useless calls in readline method
  1236. Revision 1.14 2002/09/10 12:19:14 pierre
  1237. * use faster method for loading files by default
  1238. Revision 1.13 2002/09/09 06:58:27 pierre
  1239. + FastBufStream.readline method added
  1240. Revision 1.12 2002/09/07 15:40:50 peter
  1241. * old logs removed and tabs fixed
  1242. Revision 1.11 2002/09/06 09:53:53 pierre
  1243. * explicitly set BasePos to zero in TFastBufStream constructor
  1244. Revision 1.10 2002/08/29 07:59:46 pierre
  1245. CVS: Enter log comment for commit
  1246. + SizeOfFile function added
  1247. Revision 1.9 2002/05/13 13:44:33 peter
  1248. * fixed range error
  1249. Revision 1.8 2002/04/02 13:23:02 pierre
  1250. + HextToCard StrToCard new functions
  1251. Revision 1.7 2002/03/22 16:43:27 pierre
  1252. * avoid that constructor is proposed for code complete if const is given
  1253. Revision 1.6 2002/03/20 13:48:31 pierre
  1254. * avoid stack corruption in CharStr if count > 255
  1255. }