home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / euphoria / file.e < prev    next >
Text File  |  1994-02-17  |  1KB  |  54 lines

  1.         -- Random Access File Operations --
  2.         -- plus directory functions      --
  3.  
  4. constant M_SEEK  = 19,
  5.      M_WHERE = 20,
  6.      M_DIR   = 22,
  7.      M_CURRENT_DIR = 23
  8.  
  9. type file_number(integer f)
  10.     return f >= 0
  11. end type
  12.  
  13. type file_position(integer p)
  14.     return p >= -1
  15. end type
  16.  
  17. global function seek(file_number fn, file_position pos)
  18. -- seeks to a byte position in the file, 
  19. -- or to end of file if pos is -1
  20.     return machine_func(M_SEEK, {fn, pos})
  21. end function
  22.  
  23. global function where(file_number fn)
  24. -- returns the current byte position in the file
  25.     return machine_func(M_WHERE, fn)
  26. end function
  27.  
  28. global constant 
  29.     D_NAME = 1,
  30.     D_ATTRIBUTES = 2,
  31.     D_SIZE = 3,
  32.  
  33.     D_YEAR = 4,
  34.     D_MONTH = 5,
  35.     D_DAY = 6,
  36.  
  37.     D_HOUR = 7,
  38.     D_MINUTE = 8,
  39.     D_SECOND = 9
  40. global function dir(sequence name)
  41. -- returns directory information, given the name
  42. -- of a file or directory. Format returned is:
  43. -- {
  44. --  {"name1", attributes, size, year, month, day, hour, minute, second},
  45. --  {"name2 , ...                               },
  46. -- }
  47.     return machine_func(M_DIR, name)
  48. end function
  49.  
  50. global function current_dir()
  51. -- returns name of current working directory
  52.     return machine_func(M_CURRENT_DIR, 0)
  53. end function
  54.