home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / cprog / file_cl.zip / FILE_CL.HPP < prev    next >
C/C++ Source or Header  |  1992-03-28  |  4KB  |  113 lines

  1. // Header file of the File_cl class (for file objects)
  2.  
  3. // Amount of simultaneously opened files. DON'T MODIFY
  4. // Modification implies library recompilation
  5. #define MAXFIL_OPEN 17
  6.  
  7. #include <time.h>
  8.  
  9. #include "\borlandc\nat\classes\defs.hpp"
  10.  
  11. #if NAT_FILE_DEBUG
  12. // values for "control" arg of debug() method :
  13. #define DEBUG_ASSIGN 1
  14. // checks object assignation
  15. #define DEBUG_STATUS 2
  16. // status() method call required
  17.  
  18. extern FILE *ficdbg;    // debugging file (logs calls)
  19. extern int dbg_depth;    // current indentation (column #) in debugging file
  20. #define Dbg_fct_fin    dbg_depth--    // negative indentation macro
  21. #else
  22. #define Dbg_fct_fin ((void)0)
  23. #endif
  24.  
  25. // builds a pathname
  26. void pascal strcpyNameFile(char *dst, const char *quoi);
  27. // CRC-32 calculation
  28. unsigned long pascal crc_32(const unsigned char *p, unsigned int n, unsigned long crc = 0);
  29. // do not use :
  30. void File_clGiveCore(unsigned long);
  31.  
  32. #ifdef __BCPLUSPLUS__
  33. void far * _farptr_norm(void *pnt);    // Zortech's huge pointers
  34. #endif
  35.  
  36. typedef long OFFSET_T;    // offset in file
  37. typedef unsigned char ERRCOD_T;    // error code
  38.  
  39. // class of file objects
  40. class File_cl
  41. {
  42.  private:
  43.     char privateData[155];    // do not modify (for exact sizeof() calculation)
  44.  
  45.  public:
  46.     File_cl();
  47.     void classVersion(int *major, int *minor);    // version of File_cl
  48. #if NAT_FILE_DEBUG
  49.     File_cl(const File_cl&);    // copy initializer. DON'T USE
  50. #endif
  51.  
  52. #if FILE_SECURE
  53.     inline char addSecureFile(const char *name);
  54.     char initSecure(void);
  55. #endif
  56.     char assign(const char *name, const char *mode, int sizebuf=4096, unsigned char flush_frequency=0);
  57.     inline void setAbortOnErr(char s);
  58.     inline char getAbortOnErr(void);
  59.  
  60.     inline void setUsrErrFct(void (*argusr_err)(const char *, const char*, ...));
  61.     char pascal reinit(void);    // pour réassigner un objet
  62.  
  63.     OFFSET_T length(size_t *reste=NULL, size_t size_elem=1);
  64.     int fseek(OFFSET_T, int whence, char real=0);
  65.     inline OFFSET_T tell(void) const;
  66.     inline size_t fread(void *ptr, size_t size, size_t n, OFFSET_T o=-1);
  67.     inline size_t fwrite(const void *ptr, size_t size, size_t n, OFFSET_T o=-1);
  68.     int pascal fputc(int c, OFFSET_T off=-1);
  69.     int pascal fgetc(OFFSET_T off=-1);
  70.  
  71.     char flush(char ouvre=0);
  72.     int pascal flushAll(void);
  73.     inline int eof(void);
  74.     inline int error(void) const;
  75.     inline ERRCOD_T getErrCod(void) const;
  76.     int pascal fclose(void);
  77.  
  78.     inline const char *getName(void) const;
  79.     inline char isWritable(void) const;
  80.     inline char isReadable(void) const;
  81.     int pascal internFclose(void);
  82.     inline void stayOpen(void);
  83.     inline char isOpen(void) const;
  84.     void setBuf(int size_buf=0);
  85.     void maxBuf(char percent_ram=25);
  86.     char minBuf(long recup_ram=10000000L);
  87.     inline void setVerify(char c=1);
  88.     inline char getVerify(void) const;
  89.     int forceClose(int, char real_fclose=1);
  90.     char pascal setMaxFilesOpen(int x);
  91.     void giveCore(unsigned long howmuch=20000000L);
  92.     File_cl *whatFile_cl(const char *namefile) const;
  93.  
  94.     int internChmod(const char *path, char func, int attr);
  95.     void setDriveVerify(char drive, char verif=1);
  96.     int pascal unlink(char secure=0);
  97.     char pascal writeGarbage(OFFSET_T zone_size=-1);
  98.     int pascal rename(const char *);
  99.     char getCRC32(unsigned long *crc32, OFFSET_T off=0, OFFSET_T len=0);
  100.     char copy(const char *newname, OFFSET_T start=0, OFFSET_T len=0);
  101.     char copy(File_cl *, OFFSET_T start=0, OFFSET_T len=0);
  102.     char compare(File_cl *other, OFFSET_T *first_dif, OFFSET_T start1=0, OFFSET_T start2=0, OFFSET_T len=0);
  103.     char pascal move(const char *newname);
  104.     char cut(OFFSET_T where=-1, char secure=0);
  105. #if NAT_FILE_DEBUG
  106.     void pascal optimiseBuf(unsigned long core) const;
  107.     void pascal noOptiBuf(void);
  108.     unsigned long status(char complete=1) const;
  109.     inline unsigned long getNbOpensTot(void) const;
  110. #endif
  111.     ~File_cl(void);
  112. };
  113.