Rudiments
file.h
1 // Copyright (c) 1999-2018 David Muse
2 // See the COPYING file for more information.
3 
4 #ifndef RUDIMENTS_FILE_H
5 #define RUDIMENTS_FILE_H
6 
7 #include <rudiments/private/fileincludes.h>
8 
19 class RUDIMENTS_DLLSPEC file : public filedescriptor {
20  public:
21 
23  file();
24 
27  file(const file &f);
28 
31  file &operator=(const file &f);
32 
34  virtual ~file();
35 
58  virtual bool open(const char *name, int32_t flags);
59 
89  virtual bool open(const char *name,
90  int32_t flags,
91  mode_t perms);
92 
101  virtual bool create(const char *name, mode_t perms);
102 
103 
115  virtual char *getContents();
116 
127  virtual ssize_t getContents(unsigned char *buffer,
128  size_t buffersize);
129 
130 
134  virtual bool truncate() const;
135 
139  virtual bool truncate(off64_t size) const;
140 
141 
145  virtual off64_t getCurrentPosition() const;
146 
151  off64_t offset) const;
152 
157  off64_t offset) const;
158 
166  virtual off64_t setPositionRelativeToEnd(off64_t offset) const;
167 
171  virtual bool tryLockFile(int16_t type) const;
172 
177  virtual bool lockFile(int16_t type) const;
178 
193  virtual bool checkLockFile(int16_t type,
194  int16_t *conftype,
195  int16_t *confwhence,
196  off64_t *confstart,
197  off64_t *conflen) const;
198 
201  virtual bool unlockFile() const;
202 
208  virtual bool tryLockRegion(int16_t type,
209  off64_t start,
210  off64_t len) const;
211 
217  virtual bool lockRegion(int16_t type,
218  off64_t start,
219  off64_t len) const;
220 
236  virtual bool checkLockRegion(int16_t type,
237  off64_t start,
238  off64_t len,
239  int16_t *conftype,
240  int16_t *confwhence,
241  off64_t *confstart,
242  off64_t *conflen) const;
243 
248  virtual bool unlockRegion(off64_t start,
249  off64_t len) const;
250 
255  virtual bool tryLockFromCurrent(int16_t type,
256  off64_t len) const;
257 
263  virtual bool tryLockFromCurrent(int16_t type,
264  off64_t start,
265  off64_t len) const;
266 
272  virtual bool lockFromCurrent(int16_t type,
273  off64_t len) const;
274 
280  virtual bool lockFromCurrent(int16_t type,
281  off64_t start,
282  off64_t len) const;
283 
298  virtual bool checkLockFromCurrent(int16_t type,
299  off64_t len,
300  int16_t *conftype,
301  int16_t *confwhence,
302  off64_t *confstart,
303  off64_t *conflen) const;
304 
320  virtual bool checkLockFromCurrent(int16_t type,
321  off64_t start,
322  off64_t len,
323  int16_t *conftype,
324  int16_t *confwhence,
325  off64_t *confstart,
326  off64_t *conflen) const;
327 
331  virtual bool unlockFromCurrent(off64_t len) const;
332 
337  virtual bool unlockFromCurrent(off64_t start,
338  off64_t len) const;
339 
344  virtual bool tryLockFromEnd(int16_t type,
345  off64_t len) const;
346 
352  virtual bool tryLockFromEnd(int16_t type,
353  off64_t start,
354  off64_t len) const;
355 
361  virtual bool lockFromEnd(int16_t type, off64_t len) const;
362 
368  virtual bool lockFromEnd(int16_t type,
369  off64_t start,
370  off64_t len) const;
371 
386  virtual bool checkLockFromEnd(int16_t type,
387  off64_t len,
388  int16_t *conftype,
389  int16_t *confwhence,
390  off64_t *confstart,
391  off64_t *conflen) const;
392 
408  virtual bool checkLockFromEnd(int16_t type,
409  off64_t start,
410  off64_t len,
411  int16_t *conftype,
412  int16_t *confwhence,
413  off64_t *confstart,
414  off64_t *conflen) const;
415 
419  virtual bool unlockFromEnd(off64_t len) const;
420 
425  virtual bool unlockFromEnd(off64_t start,
426  off64_t len) const;
427 
433  virtual bool tryLockRemainder(int16_t type,
434  off64_t start) const;
435 
441  virtual bool lockRemainder(int16_t type,
442  off64_t start) const;
443 
459  virtual bool checkLockRemainder(int16_t type,
460  off64_t start,
461  int16_t *conftype,
462  int16_t *confwhence,
463  off64_t *confstart,
464  off64_t *conflen) const;
465 
470  virtual bool unlockRemainder(off64_t start) const;
471 
476  virtual bool tryLockRemainderFromCurrent(int16_t type) const;
477 
482  virtual bool tryLockRemainderFromCurrent(int16_t type,
483  off64_t start) const;
484 
489  virtual bool lockRemainderFromCurrent(int16_t type) const;
490 
496  virtual bool lockRemainderFromCurrent(int16_t type,
497  off64_t start) const;
498 
514  int16_t type,
515  int16_t *conftype,
516  int16_t *confwhence,
517  off64_t *confstart,
518  off64_t *conflen) const;
519 
536  int16_t type,
537  off64_t start,
538  int16_t *conftype,
539  int16_t *confwhence,
540  off64_t *confstart,
541  off64_t *conflen) const;
542 
546  virtual bool unlockRemainderFromCurrent() const;
547 
552  virtual bool unlockRemainderFromCurrent(off64_t start) const;
553 
558  virtual bool tryLockRemainderFromEnd(int16_t type) const;
559 
564  virtual bool tryLockRemainderFromEnd(int16_t type,
565  off64_t start) const;
566 
571  virtual bool lockRemainderFromEnd(int16_t type) const;
572 
577  virtual bool lockRemainderFromEnd(int16_t type,
578  off64_t start) const;
579 
595  int16_t type,
596  int16_t *conftype,
597  int16_t *confwhence,
598  off64_t *confstart,
599  off64_t *conflen) const;
600 
616  int16_t type,
617  off64_t start,
618  int16_t *conftype,
619  int16_t *confwhence,
620  off64_t *confstart,
621  off64_t *conflen) const;
622 
626  virtual bool unlockRemainderFromEnd() const;
627 
631  virtual bool unlockRemainderFromEnd(off64_t start) const;
632 
633 
643  virtual bool sequentialAccess(off64_t start,
644  size_t len) const;
645 
655  virtual bool randomAccess(off64_t start, size_t len) const;
656 
666  virtual bool onlyOnce(off64_t start, size_t len) const;
667 
677  virtual bool willNeed(off64_t start, size_t len) const;
678 
688  virtual bool wontNeed(off64_t start, size_t len) const;
689 
699  virtual bool normalAccess(off64_t start, size_t len) const;
700 
701 
709  virtual bool reserve(off64_t start, size_t len) const;
710 
711 
724  virtual bool sync() const;
725 
741  virtual bool dataSync() const;
742 
743 
749 
760 
765  virtual bool getCurrentProperties();
766 
768  virtual mode_t getPermissions() const;
769 
771  virtual uid_t getOwnerUserId() const;
772 
774  virtual gid_t getOwnerGroupId() const;
775 
777  virtual off64_t getSize() const;
778 
782  virtual blksize_t getBlockSize() const;
783 
786  virtual blkcnt_t getBlockCount() const;
787 
790  virtual int32_t isSocket() const;
791 
794  virtual int32_t isSymbolicLink() const;
795 
798  virtual int32_t isRegularFile() const;
799 
802  virtual int32_t isBlockDevice() const;
803 
806  virtual int32_t isDirectory() const;
807 
810  virtual int32_t isCharacterDevice() const;
811 
814  virtual int32_t isFifo() const;
815 
817  virtual time_t getLastAccessTime() const;
818 
823  virtual time_t getLastModificationTime() const;
824 
829  virtual time_t getLastChangeTime() const;
830 
832  virtual dev_t getDevice() const;
833 
835  virtual dev_t getDeviceType() const;
836 
838  virtual uint64_t getInode() const;
839 
841  virtual nlink_t getNumberOfHardLinks() const;
842 
843 
846  virtual bool setPermissions(mode_t perms) const;
847 
848 
851  virtual bool changeOwner(const char *newuser,
852  const char *newgroup) const;
853 
856  virtual bool changeOwner(uid_t uid, gid_t gid) const;
857 
861  virtual bool canChangeOwner() const;
862 
865  virtual int64_t maxLinks() const;
866 
867 
871 
872 
876  static bool createFile(const char *name, mode_t perms);
877 
880  static bool createFifo(const char *filename, mode_t perms);
881 
890  static int32_t createTemporaryFile(char *templatefilename);
891 
904  static int32_t createTemporaryFile(char *templatefilename,
905  mode_t perms);
906 
909  static bool createHardLink(const char *oldpath,
910  const char *newpath);
911 
915  static bool createSymbolicLink(const char *oldpath,
916  const char *newpath);
917 
924  static char *resolveSymbolicLink(const char *filename);
925 
926 
929  static bool rename(const char *oldpath,
930  const char *newpath);
931 
934  static bool remove(const char *filename);
935 
936 
939  static bool truncate(const char *filename);
940 
943  static bool truncate(const char *filename, off64_t size);
944 
945 
958  static char *getContents(const char *name);
959 
970  static ssize_t getContents(const char *name,
971  unsigned char *buffer,
972  size_t buffersize);
973 
974 
976  static bool exists(const char *filename);
977 
980  static bool readable(const char *filename);
981 
984  static bool writeable(const char *filename);
985 
988  static bool executable(const char *filename);
989 
998  static bool accessible(const char *filename, int32_t mode);
999 
1005  static bool getLastChangeTime(const char *filename,
1006  time_t *ctime);
1007 
1010  static bool setPermissions(const char *filename,
1011  mode_t perms);
1012 
1015  static bool changeOwner(const char *filename,
1016  const char *newuser,
1017  const char *newgroup);
1018 
1021  static bool changeOwner(const char *filename,
1022  uid_t uid, gid_t gid);
1023 
1026  static bool canChangeOwner(const char *filename);
1027 
1028 
1032  static bool setLastAccessTime(const char *filename,
1033  time_t lastaccesstime);
1034 
1038  static bool setLastModificationTime(const char *filename,
1039  time_t lastmodtime);
1040 
1046  const char *filename,
1047  time_t lastaccesstime,
1048  time_t lastmodtime);
1049 
1054  const char *filename);
1055 
1056 
1061  static char *dirname(const char *filename);
1062 
1066  static char *basename(const char *filename);
1067 
1073  static char *basename(const char *filename,
1074  const char *ext);
1075 
1080  static char *extension(const char *filename);
1081 
1087  static char *eightDotThree(const char *filename);
1088 
1089 
1095  static key_t generateKey(const char *filename, int32_t id);
1096 
1099  static int64_t maxLinks(const char *filename);
1100 
1101  #include <rudiments/private/file.h>
1102 };
1103 
1104 #endif
Definition: file.h:19
virtual bool unlockFromCurrent(off64_t len) const
virtual bool unlockRemainderFromEnd() const
virtual bool checkLockRemainderFromCurrent(int16_t type, off64_t start, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
static bool createSymbolicLink(const char *oldpath, const char *newpath)
static bool canChangeOwner(const char *filename)
static bool remove(const char *filename)
virtual bool tryLockRemainderFromEnd(int16_t type) const
virtual bool open(const char *name, int32_t flags)
virtual time_t getLastChangeTime() const
virtual dev_t getDeviceType() const
virtual bool lockRemainderFromEnd(int16_t type) const
virtual bool willNeed(off64_t start, size_t len) const
virtual bool unlockFromEnd(off64_t len) const
virtual bool onlyOnce(off64_t start, size_t len) const
virtual bool unlockRemainderFromCurrent(off64_t start) const
virtual int32_t isBlockDevice() const
virtual bool getCurrentProperties()
virtual bool sync() const
static bool createFile(const char *name, mode_t perms)
virtual time_t getLastModificationTime() const
virtual bool lockFromEnd(int16_t type, off64_t start, off64_t len) const
virtual bool unlockFile() const
virtual bool tryLockFile(int16_t type) const
virtual blkcnt_t getBlockCount() const
static char * getContents(const char *name)
static char * dirname(const char *filename)
virtual bool checkLockFromEnd(int16_t type, off64_t start, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
virtual bool wontNeed(off64_t start, size_t len) const
static bool setLastAccessAndModificationTimes(const char *filename)
static bool writeable(const char *filename)
static key_t generateKey(const char *filename, int32_t id)
virtual bool checkLockFromCurrent(int16_t type, off64_t start, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
virtual bool tryLockRemainder(int16_t type, off64_t start) const
virtual bool randomAccess(off64_t start, size_t len) const
virtual int32_t isDirectory() const
static char * basename(const char *filename, const char *ext)
virtual bool checkLockRemainderFromEnd(int16_t type, off64_t start, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
virtual uint64_t getInode() const
virtual bool checkLockFile(int16_t type, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
virtual blksize_t getBlockSize() const
virtual ~file()
virtual time_t getLastAccessTime() const
static bool setLastAccessTime(const char *filename, time_t lastaccesstime)
virtual bool checkLockRemainder(int16_t type, off64_t start, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
virtual bool tryLockRegion(int16_t type, off64_t start, off64_t len) const
virtual bool unlockRemainderFromEnd(off64_t start) const
virtual off64_t setPositionRelativeToBeginning(off64_t offset) const
static bool createHardLink(const char *oldpath, const char *newpath)
virtual bool truncate() const
static bool executable(const char *filename)
static int32_t createTemporaryFile(char *templatefilename)
virtual bool checkLockRegion(int16_t type, off64_t start, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
virtual nlink_t getNumberOfHardLinks() const
virtual bool tryLockFromEnd(int16_t type, off64_t len) const
virtual bool lockFromEnd(int16_t type, off64_t len) const
static bool setLastModificationTime(const char *filename, time_t lastmodtime)
virtual int32_t isCharacterDevice() const
virtual bool create(const char *name, mode_t perms)
virtual off64_t getCurrentPosition() const
virtual int32_t isSymbolicLink() const
static bool accessible(const char *filename, int32_t mode)
static char * resolveSymbolicLink(const char *filename)
virtual int32_t isRegularFile() const
virtual bool lockFile(int16_t type) const
virtual int32_t isSocket() const
static bool truncate(const char *filename)
virtual bool tryLockFromCurrent(int16_t type, off64_t len) const
static bool readable(const char *filename)
virtual void dontGetCurrentPropertiesOnOpen()
static bool rename(const char *oldpath, const char *newpath)
virtual char * getContents()
virtual bool lockRemainderFromCurrent(int16_t type) const
static bool getLastChangeTime(const char *filename, time_t *ctime)
virtual bool unlockFromEnd(off64_t start, off64_t len) const
virtual bool changeOwner(const char *newuser, const char *newgroup) const
static bool changeOwner(const char *filename, uid_t uid, gid_t gid)
virtual void getCurrentPropertiesOnOpen()
static char * basename(const char *filename)
virtual off64_t setPositionRelativeToCurrent(off64_t offset) const
virtual bool setPermissions(mode_t perms) const
virtual int32_t isFifo() const
virtual bool sequentialAccess(off64_t start, size_t len) const
static bool setPermissions(const char *filename, mode_t perms)
virtual mode_t getPermissions() const
file & operator=(const file &f)
virtual bool unlockFromCurrent(off64_t start, off64_t len) const
static int64_t maxLinks(const char *filename)
virtual bool checkLockFromCurrent(int16_t type, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
virtual bool tryLockFromEnd(int16_t type, off64_t start, off64_t len) const
virtual bool lockFromCurrent(int16_t type, off64_t start, off64_t len) const
virtual off64_t setPositionRelativeToEnd(off64_t offset) const
virtual bool tryLockRemainderFromEnd(int16_t type, off64_t start) const
virtual bool open(const char *name, int32_t flags, mode_t perms)
static bool changeOwner(const char *filename, const char *newuser, const char *newgroup)
virtual off64_t getSize() const
virtual bool lockRemainderFromEnd(int16_t type, off64_t start) const
virtual uid_t getOwnerUserId() const
virtual ssize_t getContents(unsigned char *buffer, size_t buffersize)
virtual bool lockRegion(int16_t type, off64_t start, off64_t len) const
file(const file &f)
virtual bool normalAccess(off64_t start, size_t len) const
virtual bool lockRemainderFromCurrent(int16_t type, off64_t start) const
virtual bool truncate(off64_t size) const
static bool exists(const char *filename)
virtual bool unlockRemainder(off64_t start) const
virtual void * getInternalFileStatisticsStructure()
virtual int64_t maxLinks() const
virtual bool dataSync() const
static bool createFifo(const char *filename, mode_t perms)
virtual bool changeOwner(uid_t uid, gid_t gid) const
virtual bool checkLockFromEnd(int16_t type, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
virtual bool tryLockRemainderFromCurrent(int16_t type, off64_t start) const
virtual bool reserve(off64_t start, size_t len) const
virtual bool lockFromCurrent(int16_t type, off64_t len) const
static int32_t createTemporaryFile(char *templatefilename, mode_t perms)
static ssize_t getContents(const char *name, unsigned char *buffer, size_t buffersize)
virtual bool checkLockRemainderFromCurrent(int16_t type, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
static char * eightDotThree(const char *filename)
virtual dev_t getDevice() const
virtual bool tryLockRemainderFromCurrent(int16_t type) const
static char * extension(const char *filename)
virtual bool lockRemainder(int16_t type, off64_t start) const
virtual bool checkLockRemainderFromEnd(int16_t type, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
static bool truncate(const char *filename, off64_t size)
virtual gid_t getOwnerGroupId() const
virtual bool tryLockFromCurrent(int16_t type, off64_t start, off64_t len) const
virtual bool canChangeOwner() const
static bool setLastAccessAndModificationTimes(const char *filename, time_t lastaccesstime, time_t lastmodtime)
virtual bool unlockRemainderFromCurrent() const
virtual bool unlockRegion(off64_t start, off64_t len) const
Definition: filedescriptor.h:13