typefile.inc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Run time library.
  4. Copyright (c) 1999-2000 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:'FPC_RESET_TYPED'];
  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:'FPC_REWRITE_TYPED'];
  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 :'FPC_TYPED_WRITE'];
  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 :'FPC_TYPED_READ'];
  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.8 2000-01-07 16:41:37 daniel
  69. * copyright 2000
  70. Revision 1.7 2000/01/07 16:32:25 daniel
  71. * copyright 2000 added
  72. Revision 1.6 1998/12/16 00:22:27 peter
  73. * more temp symbols removed
  74. Revision 1.5 1998/09/14 10:48:26 peter
  75. * FPC_ names
  76. * Heap manager is now system independent
  77. Revision 1.4 1998/07/02 12:16:28 carl
  78. * IoCheck routines now check for InOutRes before executing, just like TP
  79. Revision 1.3 1998/05/21 19:31:02 peter
  80. * objects compiles for linux
  81. + assign(pchar), assign(char), rename(pchar), rename(char)
  82. * fixed read_text_as_array
  83. + read_text_as_pchar which was not yet in the rtl
  84. Revision 1.2 1998/05/12 10:42:45 peter
  85. * moved getopts to inc/, all supported OS's need argc,argv exported
  86. + strpas, strlen are now exported in the systemunit
  87. * removed logs
  88. * removed $ifdef ver_above
  89. }