file.inc 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. {
  2. This file is part of the Free Pascal Run time library.
  3. Copyright (c) 1999-2000 by the Free Pascal development team
  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. {****************************************************************************
  11. subroutines For UnTyped File handling
  12. ****************************************************************************}
  13. type
  14. UnTypedFile=File;
  15. procedure InitFile(var f : file);
  16. begin
  17. FillChar(f,SizeOf(FileRec),0);
  18. FileRec(f).Handle:=UnusedHandle;
  19. FileRec(f).mode:=fmClosed;
  20. end;
  21. {$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
  22. Procedure Assign(out f:File;const Name: UnicodeString);
  23. {
  24. Assign Name to file f so it can be used with the file routines
  25. }
  26. Begin
  27. InitFile(F);
  28. {$ifdef FPC_ANSI_TEXTFILEREC}
  29. FileRec(f).Name:=ToSingleByteFileSystemEncodedFileName(Name);
  30. {$else FPC_ANSI_TEXTFILEREC}
  31. FileRec(f).Name:=Name;
  32. {$endif FPC_ANSI_TEXTFILEREC}
  33. { null terminate, since the name array is regularly used as p(wide)char }
  34. FileRec(f).Name[high(FileRec(f).Name)]:=#0;
  35. End;
  36. {$endif FPC_HAS_FEATURE_WIDESTRINGS}
  37. {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
  38. Procedure Assign(out f:File;const Name: RawByteString);
  39. {
  40. Assign Name to file f so it can be used with the file routines
  41. }
  42. Begin
  43. InitFile(F);
  44. {$ifdef FPC_ANSI_TEXTFILEREC}
  45. { ensure the characters in the record's filename are encoded correctly }
  46. FileRec(f).Name:=ToSingleByteFileSystemEncodedFileName(Name);
  47. {$else FPC_ANSI_TEXTFILEREC}
  48. FileRec(f).Name:=Name;
  49. {$endif FPC_ANSI_TEXTFILEREC}
  50. { null terminate, since the name array is regularly used as p(wide)char }
  51. FileRec(f).Name[high(FileRec(f).Name)]:=#0;
  52. End;
  53. {$endif FPC_HAS_FEATURE_ANSISTRINGS}
  54. Procedure Assign(out f:File;const Name: ShortString);
  55. {
  56. Assign Name to file f so it can be used with the file routines
  57. }
  58. Begin
  59. {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
  60. Assign(f,AnsiString(Name));
  61. {$else FPC_HAS_FEATURE_ANSISTRINGS}
  62. InitFile(f);
  63. { warning: no encoding support }
  64. FileRec(f).Name:=Name;
  65. { null terminate, since the name array is regularly used as p(wide)char }
  66. FileRec(f).Name[high(FileRec(f).Name)]:=#0;
  67. {$endif FPC_HAS_FEATURE_ANSISTRINGS}
  68. End;
  69. Procedure Assign(out f:File;const p: PAnsiChar);
  70. Begin
  71. {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
  72. Assign(f,AnsiString(p));
  73. {$else FPC_HAS_FEATURE_ANSISTRINGS}
  74. { no use in making this the one that does the work, since the name field is
  75. limited to 255 characters anyway }
  76. Assign(f,strpas(p));
  77. {$endif FPC_HAS_FEATURE_ANSISTRINGS}
  78. End;
  79. Procedure Assign(out f:File;const c: AnsiChar);
  80. Begin
  81. {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
  82. Assign(f,AnsiString(c));
  83. {$else FPC_HAS_FEATURE_ANSISTRINGS}
  84. Assign(f,ShortString(c));
  85. {$endif FPC_HAS_FEATURE_ANSISTRINGS}
  86. End;
  87. Procedure Rewrite(var f:File;l:Longint);[IOCheck];
  88. {
  89. Create file f with recordsize of l
  90. }
  91. Begin
  92. If InOutRes <> 0 then
  93. exit;
  94. Case FileRec(f).mode Of
  95. fmInOut,fmInput,fmOutput : Close(f);
  96. fmClosed : ;
  97. else
  98. Begin
  99. InOutRes:=102;
  100. exit;
  101. End;
  102. End;
  103. If l=0 Then
  104. InOutRes:=2
  105. else
  106. Begin
  107. { Reopen with filemode 2, to be Tp compatible (PFV) }
  108. Do_Open(f,PFileTextRecChar(@FileRec(f).Name),$1002,false);
  109. FileRec(f).RecSize:=l;
  110. End;
  111. End;
  112. Procedure Reset(var f:File;l:Longint);[IOCheck];
  113. {
  114. Open file f with recordsize of l and filemode
  115. }
  116. Begin
  117. If InOutRes <> 0 then
  118. Exit;
  119. Case FileRec(f).mode Of
  120. fmInOut,fmInput,fmOutput : Close(f);
  121. fmClosed : ;
  122. else
  123. Begin
  124. InOutRes:=102;
  125. exit;
  126. End;
  127. End;
  128. If l=0 Then
  129. InOutRes:=2
  130. else
  131. Begin
  132. Do_Open(f,PFileTextRecChar(@FileRec(f).Name),Filemode,false);
  133. FileRec(f).RecSize:=l;
  134. End;
  135. End;
  136. Procedure Rewrite(Var f:File);[IOCheck];
  137. {
  138. Create file with (default) 128 byte records
  139. }
  140. Begin
  141. If InOutRes <> 0 then
  142. exit;
  143. Rewrite(f,128);
  144. End;
  145. Procedure Reset(Var f:File);[IOCheck];
  146. {
  147. Open file with (default) 128 byte records
  148. }
  149. Begin
  150. If InOutRes <> 0 then
  151. exit;
  152. Reset(f,128);
  153. End;
  154. Procedure BlockWrite(Var f:File;Const Buf;Count:Int64;var Result:Int64);[IOCheck];
  155. {
  156. Write Count records from Buf to file f, return written records in result
  157. }
  158. Begin
  159. Result:=0;
  160. If InOutRes <> 0 then
  161. exit;
  162. case FileRec(f).Mode of
  163. fmInOut,fmOutput :
  164. Result:=Do_Write(FileRec(f).Handle,@Buf,Count*FileRec(f).RecSize)
  165. div FileRec(f).RecSize;
  166. fmInPut: inOutRes := 105;
  167. else InOutRes:=103;
  168. end;
  169. End;
  170. Procedure BlockWrite(Var f:File;Const Buf;Count:Longint;var Result:Longint);[IOCheck];
  171. {
  172. Write Count records from Buf to file f, return written records in result
  173. }
  174. {$ifdef EXCLUDE_COMPLEX_PROCS}
  175. begin
  176. runerror(217);
  177. end;
  178. {$else EXCLUDE_COMPLEX_PROCS}
  179. var
  180. l : Int64;
  181. Begin
  182. BlockWrite(f,Buf,Count,l);
  183. Result:=longint(l);
  184. End;
  185. {$endif EXCLUDE_COMPLEX_PROCS}
  186. Procedure BlockWrite(Var f:File;Const Buf;Count:Word;var Result:Word);[IOCheck];
  187. {
  188. Write Count records from Buf to file f, return written records in Result
  189. }
  190. {$ifdef EXCLUDE_COMPLEX_PROCS}
  191. begin
  192. runerror(217);
  193. end;
  194. {$else EXCLUDE_COMPLEX_PROCS}
  195. var
  196. l : Int64;
  197. Begin
  198. BlockWrite(f,Buf,Count,l);
  199. Result:=word(l);
  200. End;
  201. {$endif EXCLUDE_COMPLEX_PROCS}
  202. Procedure BlockWrite(Var f:File;Const Buf;Count:Cardinal;var Result:Cardinal);[IOCheck];
  203. {
  204. Write Count records from Buf to file f, return written records in Result
  205. }
  206. {$ifdef EXCLUDE_COMPLEX_PROCS}
  207. begin
  208. runerror(217);
  209. end;
  210. {$else EXCLUDE_COMPLEX_PROCS}
  211. var
  212. l : Int64;
  213. Begin
  214. BlockWrite(f,Buf,Count,l);
  215. Result:=l;
  216. End;
  217. {$endif EXCLUDE_COMPLEX_PROCS}
  218. Procedure BlockWrite(Var f:File;Const Buf;Count:Word;var Result:Integer);[IOCheck];
  219. {
  220. Write Count records from Buf to file f, return written records in Result
  221. }
  222. {$ifdef EXCLUDE_COMPLEX_PROCS}
  223. begin
  224. runerror(217);
  225. end;
  226. {$else EXCLUDE_COMPLEX_PROCS}
  227. var
  228. l : Int64;
  229. Begin
  230. BlockWrite(f,Buf,Count,l);
  231. Result:=integer(l);
  232. End;
  233. {$endif EXCLUDE_COMPLEX_PROCS}
  234. Procedure BlockWrite(Var f:File;Const Buf;Count:Longint);[IOCheck];
  235. {
  236. Write Count records from Buf to file f, if none a Read and Count>0 then
  237. InOutRes is set
  238. }
  239. {$ifdef EXCLUDE_COMPLEX_PROCS}
  240. begin
  241. runerror(217);
  242. end;
  243. {$else EXCLUDE_COMPLEX_PROCS}
  244. var
  245. Result : Int64;
  246. Begin
  247. BlockWrite(f,Buf,Count,Result);
  248. If (InOutRes=0) and (Result<Count) and (Count>0) Then
  249. InOutRes:=101;
  250. End;
  251. {$endif EXCLUDE_COMPLEX_PROCS}
  252. Procedure BlockRead(var f:File;var Buf;Count:Int64;var Result:Int64);[IOCheck];
  253. {
  254. Read Count records from file f ro Buf, return number of read records in
  255. Result
  256. }
  257. Begin
  258. Result:=0;
  259. If InOutRes <> 0 then
  260. exit;
  261. case FileRec(f).Mode of
  262. fmInOut,fmInput :
  263. Result:=Do_Read(FileRec(f).Handle,@Buf,count*FileRec(f).RecSize)
  264. div FileRec(f).RecSize;
  265. fmOutput: inOutRes := 104;
  266. else InOutRes:=103;
  267. end;
  268. End;
  269. Procedure BlockRead(var f:File;var Buf;Count:Longint;var Result:Longint);[IOCheck];
  270. {
  271. Read Count records from file f ro Buf, return number of read records in
  272. Result
  273. }
  274. {$ifdef EXCLUDE_COMPLEX_PROCS}
  275. begin
  276. runerror(217);
  277. end;
  278. {$else EXCLUDE_COMPLEX_PROCS}
  279. var
  280. l : int64;
  281. Begin
  282. BlockRead(f,Buf,Count,l);
  283. Result:=longint(l);
  284. End;
  285. {$endif EXCLUDE_COMPLEX_PROCS}
  286. Procedure BlockRead(var f:File;var Buf;count:Word;var Result:Word);[IOCheck];
  287. {
  288. Read Count records from file f to Buf, return number of read records in
  289. Result
  290. }
  291. {$ifdef EXCLUDE_COMPLEX_PROCS}
  292. begin
  293. runerror(217);
  294. end;
  295. {$else EXCLUDE_COMPLEX_PROCS}
  296. var
  297. l : int64;
  298. Begin
  299. BlockRead(f,Buf,Count,l);
  300. Result:=word(l);
  301. End;
  302. {$endif EXCLUDE_COMPLEX_PROCS}
  303. Procedure BlockRead(var f:File;var Buf;count:Cardinal;var Result:Cardinal);[IOCheck];
  304. {
  305. Read Count records from file f to Buf, return number of read records in
  306. Result
  307. }
  308. {$ifdef EXCLUDE_COMPLEX_PROCS}
  309. begin
  310. runerror(217);
  311. end;
  312. {$else EXCLUDE_COMPLEX_PROCS}
  313. var
  314. l : int64;
  315. Begin
  316. BlockRead(f,Buf,Count,l);
  317. Result:=l;
  318. End;
  319. {$endif EXCLUDE_COMPLEX_PROCS}
  320. Procedure BlockRead(var f:File;var Buf;count:Word;var Result:Integer);[IOCheck];
  321. {
  322. Read Count records from file f to Buf, return number of read records in
  323. Result
  324. }
  325. {$ifdef EXCLUDE_COMPLEX_PROCS}
  326. begin
  327. runerror(217);
  328. end;
  329. {$else EXCLUDE_COMPLEX_PROCS}
  330. var
  331. l : int64;
  332. Begin
  333. BlockRead(f,Buf,Count,l);
  334. Result:=integer(l);
  335. End;
  336. {$endif EXCLUDE_COMPLEX_PROCS}
  337. Procedure BlockRead(Var f:File;Var Buf;Count:Int64);[IOCheck];
  338. {
  339. Read Count records from file f to Buf, if none are read and Count>0 then
  340. InOutRes is set
  341. }
  342. {$ifdef EXCLUDE_COMPLEX_PROCS}
  343. begin
  344. runerror(217);
  345. end;
  346. {$else EXCLUDE_COMPLEX_PROCS}
  347. var
  348. Result : int64;
  349. Begin
  350. BlockRead(f,Buf,Count,Result);
  351. If (InOutRes=0) and (Result<Count) and (Count>0) Then
  352. InOutRes:=100;
  353. End;
  354. {$endif EXCLUDE_COMPLEX_PROCS}
  355. Function FilePos(var f:File):Int64;[IOCheck];
  356. {
  357. Return current Position In file f in records
  358. }
  359. Begin
  360. FilePos:=0;
  361. If InOutRes <> 0 then
  362. exit;
  363. case FileRec(f).Mode of
  364. fmInOut,fmInput,fmOutput :
  365. FilePos:=Do_FilePos(FileRec(f).Handle) div FileRec(f).RecSize;
  366. else
  367. InOutRes:=103;
  368. end;
  369. End;
  370. Function FileSize(var f:File):Int64;[IOCheck];
  371. {
  372. Return the size of file f in records
  373. }
  374. Begin
  375. FileSize:=0;
  376. If InOutRes <> 0 then
  377. exit;
  378. case FileRec(f).Mode of
  379. fmInOut,fmInput,fmOutput :
  380. begin
  381. if (FileRec(f).RecSize>0) then
  382. FileSize:=Do_FileSize(FileRec(f).Handle) div FileRec(f).RecSize;
  383. end;
  384. else InOutRes:=103;
  385. end;
  386. End;
  387. Function Eof(var f:File):Boolean;[IOCheck];
  388. {
  389. Return True if we're at the end of the file f, else False is returned
  390. }
  391. Begin
  392. Eof:=false;
  393. If InOutRes <> 0 then
  394. exit;
  395. case FileRec(f).Mode of
  396. {Can't use do_ routines because we need record support}
  397. fmInOut,fmInput,fmOutput : Eof:=(FileSize(f)<=FilePos(f));
  398. else InOutRes:=103;
  399. end;
  400. End;
  401. Procedure Seek(var f:File;Pos:Int64);[IOCheck];
  402. {
  403. Goto record Pos in file f
  404. }
  405. Begin
  406. If InOutRes <> 0 then
  407. exit;
  408. case FileRec(f).Mode of
  409. fmInOut,fmInput,fmOutput :
  410. Do_Seek(FileRec(f).Handle,Pos*FileRec(f).RecSize);
  411. else InOutRes:=103;
  412. end;
  413. End;
  414. Procedure Truncate(Var f:File);[IOCheck];
  415. {
  416. Truncate/Cut file f at the current record Position
  417. }
  418. Begin
  419. If InOutRes <> 0 then
  420. exit;
  421. case FileRec(f).Mode of
  422. fmInOut,fmOutput :
  423. Do_Truncate(FileRec(f).Handle,FilePos(f)*FileRec(f).RecSize);
  424. else InOutRes:=103;
  425. end;
  426. End;
  427. Procedure Close(var f:File);[IOCheck];
  428. {
  429. Close file f
  430. }
  431. Begin
  432. If InOutRes <> 0 then
  433. exit;
  434. case FileRec(f).Mode of
  435. fmInOut,fmInput,fmOutput :
  436. begin
  437. Do_Close(FileRec(f).Handle);
  438. FileRec(f).mode:=fmClosed;
  439. end
  440. else InOutRes:=103;
  441. end;
  442. End;
  443. Procedure Erase(var f : File);[IOCheck];
  444. Begin
  445. if InOutRes<>0 then
  446. exit;
  447. if FileRec(f).mode<>fmClosed then
  448. begin
  449. InOutRes:=102;
  450. exit;
  451. end;
  452. Do_Erase(PFileTextRecChar(@FileRec(f).Name),false);
  453. End;
  454. {$ifdef FPC_HAS_FEATURE_WIDESTRINGS}
  455. Procedure Rename(var f : File; const S : UnicodeString);[IOCheck];
  456. {$ifdef FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
  457. var
  458. fs: RawByteString;
  459. {$endif FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
  460. Begin
  461. if InOutRes<>0 then
  462. exit;
  463. if FileRec(f).mode<>fmClosed then
  464. begin
  465. InOutRes:=102;
  466. exit;
  467. end;
  468. {$ifdef FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
  469. { it's slightly faster to convert the unicodestring here to rawbytestring
  470. than doing it in do_rename(), because here we still know the length }
  471. fs:=ToSingleByteFileSystemEncodedFileName(s);
  472. Do_Rename(PFileTextRecChar(@FileRec(f).Name),PAnsiChar(fs),false,true);
  473. If InOutRes=0 then
  474. FileRec(f).Name:=fs
  475. {$else FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
  476. Do_Rename(PFileTextRecChar(@FileRec(f).Name),PUnicodeChar(S),false,false);
  477. If InOutRes=0 then
  478. {$ifdef FPC_ANSI_TEXTFILEREC}
  479. FileRec(f).Name:=ToSingleByteFileSystemEncodedFileName(s);
  480. {$else FPC_ANSI_TEXTFILEREC}
  481. FileRec(f).Name:=s
  482. {$endif FPC_ANSI_TEXTFILEREC}
  483. {$endif FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
  484. End;
  485. {$endif FPC_HAS_FEATURE_WIDESTRINGS}
  486. {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
  487. Procedure Rename(var f : File;const s : RawByteString);[IOCheck];
  488. var
  489. {$ifdef FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
  490. fs: RawByteString;
  491. pdst: PAnsiChar;
  492. {$else FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
  493. fs: UnicodeString;
  494. pdst: PUnicodeChar;
  495. {$endif FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
  496. dstchangeable: boolean;
  497. Begin
  498. if InOutRes<>0 then
  499. exit;
  500. if FileRec(f).mode<>fmClosed then
  501. begin
  502. InOutRes:=102;
  503. exit;
  504. end;
  505. {$ifdef FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
  506. dstchangeable:=false;
  507. pdst:=PAnsiChar(s);
  508. if StringCodePage(s)<>DefaultFileSystemCodePage then
  509. begin
  510. fs:=ToSingleByteFileSystemEncodedFileName(s);
  511. pdst:=PAnsiChar(fs);
  512. dstchangeable:=true;
  513. end
  514. else
  515. fs:=s;
  516. {$else FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
  517. { it's slightly faster to convert the rawbytestring here to unicodestring
  518. than doing it in do_rename, because here we still know the length }
  519. fs:=unicodestring(s);
  520. pdst:=PUnicodeChar(fs);
  521. dstchangeable:=true;
  522. {$endif FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
  523. Do_Rename(PFileTextRecChar(@FileRec(f).Name),pdst,false,dstchangeable);
  524. If InOutRes=0 then
  525. {$if defined(FPC_ANSI_TEXTFILEREC) and not defined(FPCRTL_FILESYSTEM_SINGLE_BYTE_API)}
  526. FileRec(f).Name:=ToSingleByteFileSystemEncodedFileName(fs)
  527. {$else FPC_ANSI_TEXTFILEREC and not FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
  528. FileRec(f).Name:=fs
  529. {$endif FPC_ANSI_TEXTFILEREC and not FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
  530. End;
  531. {$endif FPC_HAS_FEATURE_ANSISTRINGS}
  532. Procedure Rename(var f : File;const s : ShortString);[IOCheck];
  533. {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
  534. Begin
  535. Rename(f,AnsiString(s));
  536. End;
  537. {$else FPC_HAS_FEATURE_ANSISTRINGS}
  538. var
  539. p : array[0..255] Of Char;
  540. Begin
  541. Move(s[1],p,Length(s));
  542. p[Length(s)]:=#0;
  543. Rename(f,Pchar(@p));
  544. End;
  545. {$endif FPC_HAS_FEATURE_ANSISTRINGS}
  546. Procedure Rename(var f:File;const p : PAnsiChar);[IOCheck];
  547. {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
  548. Begin
  549. Rename(f,AnsiString(p));
  550. End;
  551. {$else FPC_HAS_FEATURE_ANSISTRINGS}
  552. var
  553. len: SizeInt;
  554. Begin
  555. if InOutRes<>0 then
  556. exit;
  557. if FileRec(f).mode<>fmClosed then
  558. begin
  559. InOutRes:=102;
  560. exit;
  561. end;
  562. Do_Rename(PFileTextRecChar(@FileRec(f).Name),p,false,false);
  563. { check error code of do_rename }
  564. if InOutRes=0 then
  565. begin
  566. len:=min(StrLen(p),high(FileRec(f).Name));
  567. Move(p^,FileRec(f).Name,len);
  568. FileRec(f).Name[len]:=#0;
  569. end;
  570. End;
  571. {$endif FPC_HAS_FEATURE_ANSISTRINGS}
  572. Procedure Rename(var f:File;const c : AnsiChar);[IOCheck];
  573. {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
  574. Begin
  575. Rename(f,AnsiString(c));
  576. End;
  577. {$else FPC_HAS_FEATURE_ANSISTRINGS}
  578. var
  579. p : array[0..1] Of AnsiChar;
  580. Begin
  581. p[0]:=c;
  582. p[1]:=#0;
  583. Rename(f,PAnsiChar(@p));
  584. End;
  585. {$endif FPC_HAS_FEATURE_ANSISTRINGS}