typefile.inc 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Run time library.
  4. Copyright (c) 1993,97 by the Free Pascal development team
  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. {****************************************************************************
  12. subroutines for typed file handling
  13. ****************************************************************************}
  14. Procedure assign(var f:TypedFile;const Name:string);
  15. {
  16. Assign Name to file f so it can be used with the file routines
  17. }
  18. Begin
  19. FillChar(f,SizeOF(FileRec),0);
  20. FileRec(f).Handle:=UnusedHandle;
  21. FileRec(f).mode:=fmClosed;
  22. Move(Name[1],FileRec(f).Name,Length(Name));
  23. End;
  24. Procedure assign(var f:TypedFile;p:pchar);
  25. {
  26. Assign Name to file f so it can be used with the file routines
  27. }
  28. begin
  29. Assign(f,StrPas(p));
  30. end;
  31. Procedure assign(var f:TypedFile;c:char);
  32. {
  33. Assign Name to file f so it can be used with the file routines
  34. }
  35. begin
  36. Assign(f,string(c));
  37. end;
  38. Procedure Int_Typed_Reset(var f : TypedFile;Size : Longint);[Public,IOCheck, Alias: 'RESET_TYPED'];
  39. Begin
  40. If InOutRes <> 0 then exit;
  41. Reset(UnTypedFile(f),Size);
  42. End;
  43. Procedure Int_Typed_Rewrite(var f : TypedFile;Size : Longint);[Public,IOCheck, Alias: 'REWRITE_TYPED'];
  44. Begin
  45. If InOutRes <> 0 then exit;
  46. Rewrite(UnTypedFile(f),Size);
  47. End;
  48. Procedure Int_Typed_Write(TypeSize : Longint;var f : TypedFile;var Buf);[IOCheck, Public, Alias : 'TYPED_WRITE'];
  49. Begin
  50. If InOutRes <> 0 then exit;
  51. Do_Write(FileRec(f).Handle,Longint(@Buf),TypeSize);
  52. End;
  53. Procedure Int_Typed_Read(TypeSize : Longint;var f : TypedFile;var Buf);[IOCheck, Public, Alias : 'TYPED_READ'];
  54. var
  55. Result : Longint;
  56. Begin
  57. If InOutRes <> 0 then exit;
  58. Result:=Do_Read(FileRec(f).Handle,Longint(@Buf),TypeSize);
  59. If Result<TypeSize Then
  60. InOutRes:=100;
  61. End;
  62. {
  63. $Log$
  64. Revision 1.4 1998-07-02 12:16:28 carl
  65. * IoCheck routines now check for InOutRes before executing, just like TP
  66. Revision 1.3 1998/05/21 19:31:02 peter
  67. * objects compiles for linux
  68. + assign(pchar), assign(char), rename(pchar), rename(char)
  69. * fixed read_text_as_array
  70. + read_text_as_pchar which was not yet in the rtl
  71. Revision 1.2 1998/05/12 10:42:45 peter
  72. * moved getopts to inc/, all supported OS's need argc,argv exported
  73. + strpas, strlen are now exported in the systemunit
  74. * removed logs
  75. * removed $ifdef ver_above
  76. }