misc_file.h 946 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * misc_file.h
  3. * prototypes for misc_file.c
  4. *
  5. */
  6. #ifndef _EGG_MISC_FILE_H
  7. #define _EGG_MISC_FILE_H
  8. #include <stdio.h>
  9. int copyfile(const char *, const char *);
  10. int movefile(const char *, const char *);
  11. int is_file(const char *);
  12. int can_stat(const char *);
  13. int can_lstat(const char *);
  14. int is_symlink(const char *);
  15. int is_dir(const char *);
  16. int fixmod(const char *);
  17. class Tempfile
  18. {
  19. public:
  20. Tempfile() { Tempfile(NULL); }; //constructor
  21. Tempfile(const char *prefix, bool useFopen = 1); //constructor with file prefix
  22. void AllocTempfile(); //constructor with file prefix
  23. void my_close();
  24. ~Tempfile(); //destructor
  25. static bool FindDir();
  26. bool error; //exceptions are lame.
  27. FILE *f;
  28. char *file;
  29. int fd;
  30. size_t len;
  31. private:
  32. char *prefix;
  33. int plen;
  34. void MakeTemp(); //Used for mktemp() and checking
  35. bool useFopen;
  36. };
  37. #endif /* _EGG_MISC_FILE_H */