misc_file.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #define BINMOD S_IRUSR | S_IWUSR | S_IXUSR
  10. int copyfile(const char *, const char *);
  11. int movefile(const char *, const char *);
  12. int is_file(const char *) __attribute__((pure));
  13. int can_stat(const char *) __attribute__((pure));
  14. int can_lstat(const char *) __attribute__((pure));
  15. int is_symlink(const char *) __attribute__((pure));
  16. int is_dir(const char *) __attribute__((pure));
  17. int fixmod(const char *);
  18. class Tempfile
  19. {
  20. public:
  21. Tempfile() { Tempfile(NULL); }; //constructor
  22. Tempfile(const char *prefix, bool useFopen = 1); //constructor with file prefix
  23. void AllocTempfile(); //constructor with file prefix
  24. void my_close();
  25. ~Tempfile(); //destructor
  26. static bool FindDir() noexcept;
  27. bool error; //exceptions are lame.
  28. FILE *f;
  29. char *file;
  30. int fd;
  31. size_t len;
  32. private:
  33. char *prefix;
  34. int plen;
  35. void MakeTemp() noexcept; //Used for mktemp() and checking
  36. bool useFopen;
  37. };
  38. #endif /* _EGG_MISC_FILE_H */