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 
116  virtual char *getContents();
117 
128  virtual ssize_t getContents(unsigned char *buffer,
129  size_t buffersize);
130 
131 
135  virtual bool truncate() const;
136 
140  virtual bool truncate(off64_t length) const;
141 
142 
146  virtual off64_t getCurrentPosition() const;
147 
151  virtual off64_t setPositionRelativeToBeginning(
152  off64_t offset) const;
153 
157  virtual off64_t setPositionRelativeToCurrent(
158  off64_t offset) const;
159 
167  virtual off64_t setPositionRelativeToEnd(off64_t offset) const;
168 
172  virtual bool tryLockFile(int16_t type) const;
173 
178  virtual bool lockFile(int16_t type) const;
179 
194  virtual bool checkLockFile(int16_t type,
195  int16_t *conftype,
196  int16_t *confwhence,
197  off64_t *confstart,
198  off64_t *conflen) const;
199 
202  virtual bool unlockFile() const;
203 
209  virtual bool tryLockRegion(int16_t type,
210  off64_t start,
211  off64_t len) const;
212 
218  virtual bool lockRegion(int16_t type,
219  off64_t start,
220  off64_t len) const;
221 
237  virtual bool checkLockRegion(int16_t type,
238  off64_t start,
239  off64_t len,
240  int16_t *conftype,
241  int16_t *confwhence,
242  off64_t *confstart,
243  off64_t *conflen) const;
244 
249  virtual bool unlockRegion(off64_t start,
250  off64_t len) const;
251 
256  virtual bool tryLockFromCurrent(int16_t type,
257  off64_t len) const;
258 
264  virtual bool tryLockFromCurrent(int16_t type,
265  off64_t start,
266  off64_t len) const;
267 
273  virtual bool lockFromCurrent(int16_t type,
274  off64_t len) const;
275 
281  virtual bool lockFromCurrent(int16_t type,
282  off64_t start,
283  off64_t len) const;
284 
299  virtual bool checkLockFromCurrent(int16_t type,
300  off64_t len,
301  int16_t *conftype,
302  int16_t *confwhence,
303  off64_t *confstart,
304  off64_t *conflen) const;
305 
321  virtual bool checkLockFromCurrent(int16_t type,
322  off64_t start,
323  off64_t len,
324  int16_t *conftype,
325  int16_t *confwhence,
326  off64_t *confstart,
327  off64_t *conflen) const;
328 
332  virtual bool unlockFromCurrent(off64_t len) const;
333 
338  virtual bool unlockFromCurrent(off64_t start,
339  off64_t len) const;
340 
345  virtual bool tryLockFromEnd(int16_t type,
346  off64_t len) const;
347 
353  virtual bool tryLockFromEnd(int16_t type,
354  off64_t start,
355  off64_t len) const;
356 
362  virtual bool lockFromEnd(int16_t type, off64_t len) const;
363 
369  virtual bool lockFromEnd(int16_t type,
370  off64_t start,
371  off64_t len) const;
372 
387  virtual bool checkLockFromEnd(int16_t type,
388  off64_t len,
389  int16_t *conftype,
390  int16_t *confwhence,
391  off64_t *confstart,
392  off64_t *conflen) const;
393 
409  virtual bool checkLockFromEnd(int16_t type,
410  off64_t start,
411  off64_t len,
412  int16_t *conftype,
413  int16_t *confwhence,
414  off64_t *confstart,
415  off64_t *conflen) const;
416 
420  virtual bool unlockFromEnd(off64_t len) const;
421 
426  virtual bool unlockFromEnd(off64_t start,
427  off64_t len) const;
428 
434  virtual bool tryLockRemainder(int16_t type,
435  off64_t start) const;
436 
442  virtual bool lockRemainder(int16_t type,
443  off64_t start) const;
444 
460  virtual bool checkLockRemainder(int16_t type,
461  off64_t start,
462  int16_t *conftype,
463  int16_t *confwhence,
464  off64_t *confstart,
465  off64_t *conflen) const;
466 
471  virtual bool unlockRemainder(off64_t start) const;
472 
477  virtual bool tryLockRemainderFromCurrent(int16_t type) const;
478 
483  virtual bool tryLockRemainderFromCurrent(int16_t type,
484  off64_t start) const;
485 
490  virtual bool lockRemainderFromCurrent(int16_t type) const;
491 
497  virtual bool lockRemainderFromCurrent(int16_t type,
498  off64_t start) const;
499 
514  virtual bool checkLockRemainderFromCurrent(
515  int16_t type,
516  int16_t *conftype,
517  int16_t *confwhence,
518  off64_t *confstart,
519  off64_t *conflen) const;
520 
536  virtual bool checkLockRemainderFromCurrent(
537  int16_t type,
538  off64_t start,
539  int16_t *conftype,
540  int16_t *confwhence,
541  off64_t *confstart,
542  off64_t *conflen) const;
543 
547  virtual bool unlockRemainderFromCurrent() const;
548 
553  virtual bool unlockRemainderFromCurrent(off64_t start) const;
554 
559  virtual bool tryLockRemainderFromEnd(int16_t type) const;
560 
565  virtual bool tryLockRemainderFromEnd(int16_t type,
566  off64_t start) const;
567 
572  virtual bool lockRemainderFromEnd(int16_t type) const;
573 
578  virtual bool lockRemainderFromEnd(int16_t type,
579  off64_t start) const;
580 
595  virtual bool checkLockRemainderFromEnd(
596  int16_t type,
597  int16_t *conftype,
598  int16_t *confwhence,
599  off64_t *confstart,
600  off64_t *conflen) const;
601 
616  virtual bool checkLockRemainderFromEnd(
617  int16_t type,
618  off64_t start,
619  int16_t *conftype,
620  int16_t *confwhence,
621  off64_t *confstart,
622  off64_t *conflen) const;
623 
627  virtual bool unlockRemainderFromEnd() const;
628 
632  virtual bool unlockRemainderFromEnd(off64_t start) const;
633 
634 
644  virtual bool sequentialAccess(off64_t start,
645  size_t len) const;
646 
656  virtual bool randomAccess(off64_t start, size_t len) const;
657 
667  virtual bool onlyOnce(off64_t start, size_t len) const;
668 
678  virtual bool willNeed(off64_t start, size_t len) const;
679 
689  virtual bool wontNeed(off64_t start, size_t len) const;
690 
700  virtual bool normalAccess(off64_t start, size_t len) const;
701 
702 
710  virtual bool reserve(off64_t start, size_t len) const;
711 
712 
725  virtual bool sync() const;
726 
742  virtual bool dataSync() const;
743 
744 
749  virtual void dontGetCurrentPropertiesOnOpen();
750 
760  virtual void getCurrentPropertiesOnOpen();
761 
766  virtual bool getCurrentProperties();
767 
769  virtual mode_t getPermissions() const;
770 
772  virtual uid_t getOwnerUserId() const;
773 
775  virtual gid_t getOwnerGroupId() const;
776 
778  virtual off64_t getSize() const;
779 
783  virtual blksize_t getBlockSize() const;
784 
787  virtual blkcnt_t getBlockCount() const;
788 
791  virtual int32_t isSocket() const;
792 
795  virtual int32_t isSymbolicLink() const;
796 
799  virtual int32_t isRegularFile() const;
800 
803  virtual int32_t isBlockDevice() const;
804 
807  virtual int32_t isDirectory() const;
808 
811  virtual int32_t isCharacterDevice() const;
812 
815  virtual int32_t isFifo() const;
816 
818  virtual time_t getLastAccessTime() const;
819 
824  virtual time_t getLastModificationTime() const;
825 
830  virtual time_t getLastChangeTime() const;
831 
833  virtual dev_t getDevice() const;
834 
836  virtual dev_t getDeviceType() const;
837 
839  virtual uint64_t getInode() const;
840 
842  virtual nlink_t getNumberOfHardLinks() const;
843 
844 
847  virtual bool setPermissions(mode_t perms) const;
848 
849 
852  virtual bool changeOwner(const char *newuser,
853  const char *newgroup) const;
854 
857  virtual bool changeOwner(uid_t uid, gid_t gid) const;
858 
862  virtual bool canChangeOwner() const;
863 
866  virtual int64_t maxLinks() const;
867 
868 
871  virtual void *getInternalFileStatisticsStructure();
872 
873 
877  static bool createFile(const char *name, mode_t perms);
878 
881  static bool createFifo(const char *filename, mode_t perms);
882 
891  static int32_t createTemporaryFile(char *templatefilename);
892 
905  static int32_t createTemporaryFile(char *templatefilename,
906  mode_t perms);
907 
910  static bool createHardLink(const char *oldpath,
911  const char *newpath);
912 
916  static bool createSymbolicLink(const char *oldpath,
917  const char *newpath);
918 
925  static char *resolveSymbolicLink(const char *filename);
926 
927 
930  static bool rename(const char *oldpath,
931  const char *newpath);
932 
935  static bool remove(const char *filename);
936 
937 
940  static bool truncate(const char *filename);
941 
944  static bool truncate(const char *filename, off64_t length);
945 
946 
959  static char *getContents(const char *name);
960 
971  static ssize_t getContents(const char *name,
972  unsigned char *buffer,
973  size_t buffersize);
974 
975 
977  static bool exists(const char *filename);
978 
981  static bool readable(const char *filename);
982 
985  static bool writeable(const char *filename);
986 
989  static bool executable(const char *filename);
990 
999  static bool accessible(const char *filename, int32_t mode);
1000 
1006  static bool getLastChangeTime(const char *filename,
1007  time_t *ctime);
1008 
1011  static bool setPermissions(const char *filename,
1012  mode_t perms);
1013 
1016  static bool changeOwner(const char *filename,
1017  const char *newuser,
1018  const char *newgroup);
1019 
1022  static bool changeOwner(const char *filename,
1023  uid_t uid, gid_t gid);
1024 
1027  static bool canChangeOwner(const char *filename);
1028 
1029 
1033  static bool setLastAccessTime(const char *filename,
1034  time_t lastaccesstime);
1035 
1039  static bool setLastModificationTime(const char *filename,
1040  time_t lastmodtime);
1041 
1046  static bool setLastAccessAndModificationTimes(
1047  const char *filename,
1048  time_t lastaccesstime,
1049  time_t lastmodtime);
1050 
1054  static bool setLastAccessAndModificationTimes(
1055  const char *filename);
1056 
1057 
1062  static char *dirname(const char *filename);
1063 
1067  static char *basename(const char *filename);
1068 
1074  static char *basename(const char *filename,
1075  const char *suffix);
1076 
1082  static char *eightDotThree(const char *filename);
1083 
1084 
1090  static key_t generateKey(const char *filename, int32_t id);
1091 
1094  static int64_t maxLinks(const char *filename);
1095 
1096  #include <rudiments/private/file.h>
1097 };
1098 
1099 #endif
Definition: file.h:19
filedescriptor & operator=(const filedescriptor &f)
Definition: filedescriptor.h:13