wutils.pas 32 KB

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