typefile.inc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. Reset(UnTypedFile(f),Size);
  41. End;
  42. Procedure Int_Typed_Rewrite(var f : TypedFile;Size : Longint);[Public,IOCheck, Alias: 'REWRITE_TYPED'];
  43. Begin
  44. Rewrite(UnTypedFile(f),Size);
  45. End;
  46. Procedure Int_Typed_Write(TypeSize : Longint;var f : TypedFile;var Buf);[IOCheck, Public, Alias : 'TYPED_WRITE'];
  47. Begin
  48. Do_Write(FileRec(f).Handle,Longint(@Buf),TypeSize);
  49. End;
  50. Procedure Int_Typed_Read(TypeSize : Longint;var f : TypedFile;var Buf);[IOCheck, Public, Alias : 'TYPED_READ'];
  51. var
  52. Result : Longint;
  53. Begin
  54. Result:=Do_Read(FileRec(f).Handle,Longint(@Buf),TypeSize);
  55. If Result<TypeSize Then
  56. InOutRes:=100;
  57. End;
  58. {
  59. $Log$
  60. Revision 1.3 1998-05-21 19:31:02 peter
  61. * objects compiles for linux
  62. + assign(pchar), assign(char), rename(pchar), rename(char)
  63. * fixed read_text_as_array
  64. + read_text_as_pchar which was not yet in the rtl
  65. Revision 1.2 1998/05/12 10:42:45 peter
  66. * moved getopts to inc/, all supported OS's need argc,argv exported
  67. + strpas, strlen are now exported in the systemunit
  68. * removed logs
  69. * removed $ifdef ver_above
  70. }