typefile.inc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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.9 2000-02-09 16:59:31 peter
  69. * truncated log
  70. Revision 1.8 2000/01/07 16:41:37 daniel
  71. * copyright 2000
  72. Revision 1.7 2000/01/07 16:32:25 daniel
  73. * copyright 2000 added
  74. }