typefile.inc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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: {$ifdef FPCNAMES}'FPC_RESET_TYPED'{$else}'RESET_TYPED'{$endif}];
  39. Begin
  40. If InOutRes <> 0 then
  41. exit;
  42. Reset(UnTypedFile(f),Size);
  43. End;
  44. Procedure Int_Typed_Rewrite(var f : TypedFile;Size : Longint);[Public,IOCheck, Alias: {$ifdef FPCNAMES}'FPC_REWRITE_TYPED'{$else}'REWRITE_TYPED'{$endif}];
  45. Begin
  46. If InOutRes <> 0 then
  47. exit;
  48. Rewrite(UnTypedFile(f),Size);
  49. End;
  50. Procedure Int_Typed_Write(TypeSize : Longint;var f : TypedFile;var Buf);[IOCheck, Public, Alias : {$ifdef FPCNAMES}'FPC_TYPED_WRITE'{$else}'TYPED_WRITE'{$endif}];
  51. Begin
  52. If InOutRes <> 0 then
  53. exit;
  54. Do_Write(FileRec(f).Handle,Longint(@Buf),TypeSize);
  55. End;
  56. Procedure Int_Typed_Read(TypeSize : Longint;var f : TypedFile;var Buf);[IOCheck, Public, Alias : {$ifdef FPCNAMES}'FPC_TYPED_READ'{$else}'TYPED_READ'{$endif}];
  57. var
  58. Result : Longint;
  59. Begin
  60. If InOutRes <> 0 then
  61. exit;
  62. Result:=Do_Read(FileRec(f).Handle,Longint(@Buf),TypeSize);
  63. If Result<TypeSize Then
  64. InOutRes:=100;
  65. End;
  66. {
  67. $Log$
  68. Revision 1.5 1998-09-14 10:48:26 peter
  69. * FPC_ names
  70. * Heap manager is now system independent
  71. Revision 1.4 1998/07/02 12:16:28 carl
  72. * IoCheck routines now check for InOutRes before executing, just like TP
  73. Revision 1.3 1998/05/21 19:31:02 peter
  74. * objects compiles for linux
  75. + assign(pchar), assign(char), rename(pchar), rename(char)
  76. * fixed read_text_as_array
  77. + read_text_as_pchar which was not yet in the rtl
  78. Revision 1.2 1998/05/12 10:42:45 peter
  79. * moved getopts to inc/, all supported OS's need argc,argv exported
  80. + strpas, strlen are now exported in the systemunit
  81. * removed logs
  82. * removed $ifdef ver_above
  83. }