home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 2.ddi / RTLINSRC.ZIP / FILESYS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  2.8 KB  |  75 lines

  1. /*------------------------------------------------------------------------
  2.  * filename - filesys.h
  3.  *
  4.  *      interface to file system
  5.  *-----------------------------------------------------------------------*/
  6.  
  7. /*[]------------------------------------------------------------[]*/
  8. /*|                                                              |*/
  9. /*|     C/C++ Run Time Library - Version 4.0                     |*/
  10. /*|                                                              |*/
  11. /*|                                                              |*/
  12. /*|     Copyright (c) 1987, 1991 by Borland International        |*/
  13. /*|     All Rights Reserved.                                     |*/
  14. /*|                                                              |*/
  15. /*[]------------------------------------------------------------[]*/
  16.  
  17. /*
  18.  * The following declarations will need to be adjusted for the
  19.  * operating system in use.
  20.  *
  21.  * We assume a Unix-like model.  If yours is very different, additional
  22.  * interface functions will be needed, or some rewriting of the
  23.  * implementation which uses these functions and data.
  24.  */
  25.  
  26. #include <fcntl.h>
  27. #include <sys/stat.h>
  28. #include <io.h>
  29.  
  30. // Assume the following OS routines return this value on error,
  31. // and that this value is NOT ZERO.
  32. // Assume they also set errno when needed.
  33. const int OS_err = -1;  
  34.  
  35. // open file, return fd, open mode 'how', protection 'prot'
  36. //extern "C" int open(const char *name, int how, int prot);
  37. // 'how' bits, these values for SUN OS (like BSD Unix)
  38. const int O_rdonly = O_RDONLY;  // read only
  39. const int O_wronly = O_WRONLY;  // write only
  40. const int O_rdwr   = O_RDWR;    // read and write
  41. const int O_append = O_APPEND;  // append at each write
  42. const int O_create = O_CREAT;   // create file if it does not exist
  43. const int O_trunc  = O_TRUNC;   // truncate file length to 0 if exists
  44. const int O_excl   = O_EXCL;    // error if create and file exists
  45.  
  46. // close file, return 0 on success
  47. //extern "C" int close(int fd);
  48.  
  49. // read 'count' chars into 'buf', return number read
  50. //extern "C" int read(int fd, void* buf, unsigned count);
  51.  
  52. // write 'count' chars from 'buf', return number written
  53. //extern "C" int write(int fd, void* buf, unsigned count);
  54.  
  55. // seek to 'offset' relative to 'whence',
  56. // return new file position, long(OS_err) on error (set errno)
  57. //extern "C" long lseek(int fd, long offset, int whence);
  58. // values for 'whence':
  59. const int L_set = SEEK_SET;     // from beginning
  60. const int L_cur = SEEK_CUR;     // from current pos
  61. const int L_end = SEEK_END;     // from end
  62.  
  63.  
  64. // natural size for a file buffer, plus 4 for putback
  65. const int B_size = 516;
  66.  
  67. // default protection bits
  68. const int P_default = S_IREAD | S_IWRITE;
  69.  
  70.  
  71. // fd numbers for standard in, out, error
  72. const int F_stdin = 0;
  73. const int F_stdout = 1;
  74. const int F_stderr = 2;
  75.