UXFILES.DEF 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. (* ========================================================= *)
  2. (* Preliminary library module for Gardens Point Modula *)
  3. (* ========================================================= *)
  4. FOREIGN DEFINITION MODULE UxFiles;
  5. IMPORT IMPLEMENTATION FROM "uxfiles.obj";
  6. (*
  7. * WARNING WARNING: THIS IS THE MSDOS VERSION. FILE *
  8. * PERMISSION BITS ARE DIFFERENT TO THE UNIX VERSIONS *
  9. *
  10. * This module provides the low level interface to the *
  11. * UNIX file system, it links to the library <stdio.h> *
  12. * The user programs are protected against the UNIX *
  13. * identifiers which are introduced in the header file *)
  14. FROM SYSTEM IMPORT ADDRESS, BYTE;
  15. TYPE
  16. File;
  17. OpenMode = (ReadOnly, WriteOnly, ReadWrite);
  18. FilePermissionBits =
  19. (rdOnly,hidden,system,volId,subDir,archive);
  20. FileMode =
  21. SET OF FilePermissionBits;
  22. FileAttrib = FilePermissionBits; (* synonyms for the *)
  23. FileAttSet = FileMode; (* WildCards library *)
  24. PROCEDURE GetMode( name : ARRAY OF CHAR;
  25. VAR mode : FileMode;
  26. VAR done : BOOLEAN);
  27. (* precondition : name must be a nul-terminated variable
  28. array,or a literal string.
  29. postcondition : if done then mode has permission bits *)
  30. PROCEDURE SetMode( name : ARRAY OF CHAR;
  31. mode : FileMode;
  32. VAR done : BOOLEAN);
  33. (* precondition : name must be a nul-terminated variable
  34. array,or a literal string.
  35. postcondition : if done then file has permission bits *)
  36. PROCEDURE Open(VAR f: File; (* Open an existing file *)
  37. name: ARRAY OF CHAR;
  38. mode: OpenMode;
  39. VAR done: BOOLEAN);
  40. PROCEDURE Create(VAR f: File; (* Open a new file *)
  41. name: ARRAY OF CHAR;
  42. VAR done: BOOLEAN);
  43. PROCEDURE Close(VAR f: File; (* Close a file *)
  44. VAR done: BOOLEAN);
  45. PROCEDURE Delete(str : ARRAY OF CHAR;
  46. VAR ok : BOOLEAN);
  47. PROCEDURE Reset(f: File);
  48. (* Position the file at the beginning and set to "ReadMode" *)
  49. PROCEDURE ReadNBytes( f: File;
  50. buffPtr: ADDRESS;
  51. requestedBytes: CARDINAL;
  52. VAR read: CARDINAL);
  53. (* Read requested bytes into buffer at address *)
  54. (* 'buffPtr', number of effectively read bytes *)
  55. (* is returned in 'read' *)
  56. PROCEDURE WriteNBytes( f: File;
  57. buffPtr: ADDRESS;
  58. requestedBytes: CARDINAL;
  59. VAR written: CARDINAL);
  60. (* Write requested bytes from buffer at address *)
  61. (* 'buffPtr', number of effectively written bytes *)
  62. (* is returned in 'written' *)
  63. PROCEDURE ReadByte( f: File; (* Read a byte from file *)
  64. VAR b: BYTE);
  65. (* b = 377C if an attempt is made to read past end *)
  66. (* thus (b= 377C) AND EndFile(f) is cheap eof test *)
  67. PROCEDURE WriteByte( f: File; (* Write a word to file *)
  68. b: BYTE);
  69. PROCEDURE EndFile( f : File) : BOOLEAN;
  70. (* returns true if an attempt has been made
  71. to read past the physical end of file *)
  72. PROCEDURE GetPos( f : File;
  73. VAR p : CARDINAL);
  74. PROCEDURE SetPos( f : File;
  75. p : CARDINAL);
  76. (* GetPos and SetPos get and set the file position *)
  77. PROCEDURE AccessTime(path : ARRAY OF CHAR;
  78. VAR time : CARDINAL;
  79. VAR ok : BOOLEAN);
  80. (* finds time of last access to named file *)
  81. PROCEDURE ModifyTime(path : ARRAY OF CHAR;
  82. VAR time : CARDINAL;
  83. VAR ok : BOOLEAN);
  84. (* finds time of last modification to file *)
  85. PROCEDURE StatusTime(path : ARRAY OF CHAR;
  86. VAR time : CARDINAL;
  87. VAR ok : BOOLEAN);
  88. (* finds time of last status change of file *)
  89. PROCEDURE FileSize(filePath : ARRAY OF CHAR;
  90. VAR size : CARDINAL;
  91. VAR ok : BOOLEAN);
  92. (* returns size of file "filePath" *)
  93. END UxFiles.