Rudiments: /home/dmuse/src/rudiments/include/rudiments/file.h Source File

Rudiments

- Main Page
- Classes

file.h
1 // Copyright (c) 2002 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
9 class fileprivate;
10
21 class RUDIMENTS_DLLSPEC file : public filedescriptor {
22 public:
23
25 file();
26
29 file(const file &f);
30
33 file &operator=(const file &f);
34
36 virtual ~file();
37
63 virtual bool open(const char *name, int32_t flags);
64
93 virtual bool open(const char *name,
94 int32_t flags,
95 mode_t perms);
96
103 virtual bool create(const char *name, mode_t perms);
104
105
118 virtual char *getContents();
119
130 virtual ssize_t getContents(unsigned char *buffer,
131 size_t buffersize);
132
133
137 virtual bool truncate() const;
138
142 virtual bool truncate(off64_t length) const;
143
144
148 virtual off64_t getCurrentPosition() const;
149
153 virtual off64_t setPositionRelativeToBeginning(
154 off64_t offset) const;
155
159 virtual off64_t setPositionRelativeToCurrent(
160 off64_t offset) const;
161
169 virtual off64_t setPositionRelativeToEnd(off64_t offset) const;
170
174 virtual bool tryLockFile(int16_t type) const;
175
180 virtual bool lockFile(int16_t type) const;
181
196 virtual bool checkLockFile(int16_t type,
197 int16_t *conftype,
198 int16_t *confwhence,
199 off64_t *confstart,
200 off64_t *conflen) const;
201
204 virtual bool unlockFile() const;
205
211 virtual bool tryLockRegion(int16_t type,
212 off64_t start,
213 off64_t len) const;
214
220 virtual bool lockRegion(int16_t type,
221 off64_t start,
222 off64_t len) const;
223
239 virtual bool checkLockRegion(int16_t type,
240 off64_t start,
241 off64_t len,
242 int16_t *conftype,
243 int16_t *confwhence,
244 off64_t *confstart,
245 off64_t *conflen) const;
246
251 virtual bool unlockRegion(off64_t start,
252 off64_t len) const;
253
258 virtual bool tryLockFromCurrent(int16_t type,
259 off64_t len) const;
260
266 virtual bool tryLockFromCurrent(int16_t type,
267 off64_t start,
268 off64_t len) const;
269
275 virtual bool lockFromCurrent(int16_t type,
276 off64_t len) const;
277
283 virtual bool lockFromCurrent(int16_t type,
284 off64_t start,
285 off64_t len) const;
286
301 virtual bool checkLockFromCurrent(int16_t type,
302 off64_t len,
303 int16_t *conftype,
304 int16_t *confwhence,
305 off64_t *confstart,
306 off64_t *conflen) const;
307
323 virtual bool checkLockFromCurrent(int16_t type,
324 off64_t start,
325 off64_t len,
326 int16_t *conftype,
327 int16_t *confwhence,
328 off64_t *confstart,
329 off64_t *conflen) const;
330
334 virtual bool unlockFromCurrent(off64_t len) const;
335
340 virtual bool unlockFromCurrent(off64_t start,
341 off64_t len) const;
342
347 virtual bool tryLockFromEnd(int16_t type,
348 off64_t len) const;
349
355 virtual bool tryLockFromEnd(int16_t type,
356 off64_t start,
357 off64_t len) const;
358
364 virtual bool lockFromEnd(int16_t type, off64_t len) const;
365
371 virtual bool lockFromEnd(int16_t type,
372 off64_t start,
373 off64_t len) const;
374
389 virtual bool checkLockFromEnd(int16_t type,
390 off64_t len,
391 int16_t *conftype,
392 int16_t *confwhence,
393 off64_t *confstart,
394 off64_t *conflen) const;
395
411 virtual bool checkLockFromEnd(int16_t type,
412 off64_t start,
413 off64_t len,
414 int16_t *conftype,
415 int16_t *confwhence,
416 off64_t *confstart,
417 off64_t *conflen) const;
418
422 virtual bool unlockFromEnd(off64_t len) const;
423
428 virtual bool unlockFromEnd(off64_t start,
429 off64_t len) const;
430
436 virtual bool tryLockRemainder(int16_t type,
437 off64_t start) const;
438
444 virtual bool lockRemainder(int16_t type,
445 off64_t start) const;
446
462 virtual bool checkLockRemainder(int16_t type,
463 off64_t start,
464 int16_t *conftype,
465 int16_t *confwhence,
466 off64_t *confstart,
467 off64_t *conflen) const;
468
473 virtual bool unlockRemainder(off64_t start) const;
474
479 virtual bool tryLockRemainderFromCurrent(int16_t type) const;
480
485 virtual bool tryLockRemainderFromCurrent(int16_t type,
486 off64_t start) const;
487
492 virtual bool lockRemainderFromCurrent(int16_t type) const;
493
499 virtual bool lockRemainderFromCurrent(int16_t type,
500 off64_t start) const;
501
516 virtual bool checkLockRemainderFromCurrent(
517 int16_t type,
518 int16_t *conftype,
519 int16_t *confwhence,
520 off64_t *confstart,
521 off64_t *conflen) const;
522
538 virtual bool checkLockRemainderFromCurrent(
539 int16_t type,
540 off64_t start,
541 int16_t *conftype,
542 int16_t *confwhence,
543 off64_t *confstart,
544 off64_t *conflen) const;
545
549 virtual bool unlockRemainderFromCurrent() const;
550
555 virtual bool unlockRemainderFromCurrent(off64_t start) const;
556
561 virtual bool tryLockRemainderFromEnd(int16_t type) const;
562
567 virtual bool tryLockRemainderFromEnd(int16_t type,
568 off64_t start) const;
569
574 virtual bool lockRemainderFromEnd(int16_t type) const;
575
580 virtual bool lockRemainderFromEnd(int16_t type,
581 off64_t start) const;
582
597 virtual bool checkLockRemainderFromEnd(
598 int16_t type,
599 int16_t *conftype,
600 int16_t *confwhence,
601 off64_t *confstart,
602 off64_t *conflen) const;
603
618 virtual bool checkLockRemainderFromEnd(
619 int16_t type,
620 off64_t start,
621 int16_t *conftype,
622 int16_t *confwhence,
623 off64_t *confstart,
624 off64_t *conflen) const;
625
629 virtual bool unlockRemainderFromEnd() const;
630
634 virtual bool unlockRemainderFromEnd(off64_t start) const;
635
636
646 virtual bool sequentialAccess(off64_t start,
647 size_t len) const;
648
658 virtual bool randomAccess(off64_t start, size_t len) const;
659
669 virtual bool onlyOnce(off64_t start, size_t len) const;
670
680 virtual bool willNeed(off64_t start, size_t len) const;
681
691 virtual bool wontNeed(off64_t start, size_t len) const;
692
702 virtual bool normalAccess(off64_t start, size_t len) const;
703
704
712 virtual bool reserve(off64_t start, size_t len) const;
713
714
727 virtual bool sync() const;
728
744 virtual bool dataSync() const;
745
746
751 virtual void dontGetCurrentPropertiesOnOpen();
752
762 virtual void getCurrentPropertiesOnOpen();
763
768 virtual bool getCurrentProperties();
769
771 virtual mode_t getPermissions() const;
772
774 virtual uid_t getOwnerUserId() const;
775
777 virtual gid_t getOwnerGroupId() const;
778
780 virtual off64_t getSize() const;
781
785 virtual blksize_t getBlockSize() const;
786
789 virtual blkcnt_t getBlockCount() const;
790
793 virtual int32_t isSocket() const;
794
797 virtual int32_t isSymbolicLink() const;
798
801 virtual int32_t isRegularFile() const;
802
805 virtual int32_t isBlockDevice() const;
806
809 virtual int32_t isDirectory() const;
810
813 virtual int32_t isCharacterDevice() const;
814
817 virtual int32_t isFifo() const;
818
820 virtual time_t getLastAccessTime() const;
821
826 virtual time_t getLastModificationTime() const;
827
832 virtual time_t getLastChangeTime() const;
833
835 virtual dev_t getDevice() const;
836
838 virtual dev_t getDeviceType() const;
839
841 virtual uint64_t getInode() const;
842
844 virtual nlink_t getNumberOfHardLinks() const;
845
846
849 virtual bool setPermissions(mode_t perms) const;
850
851
854 virtual bool changeOwner(const char *newuser,
855 const char *newgroup) const;
856
859 virtual bool changeOwner(uid_t uid, gid_t gid) const;
860
864 virtual bool canChangeOwner() const;
865
868 virtual int64_t maxLinks() const;
869
870
873 virtual void *getInternalFileStatisticsStructure();
874
875
879 static bool createFile(const char *name, mode_t perms);
880
883 static bool createFifo(const char *filename, mode_t perms);
884
893 static int32_t createTemporaryFile(char *templatefilename);
894
907 static int32_t createTemporaryFile(char *templatefilename,
908 mode_t perms);
909
912 static bool createHardLink(const char *oldpath,
913 const char *newpath);
914
918 static bool createSymbolicLink(const char *oldpath,
919 const char *newpath);
920
927 static char *resolveSymbolicLink(const char *filename);
928
929
932 static bool rename(const char *oldpath,
933 const char *newpath);
934
937 static bool remove(const char *filename);
938
939
942 static bool truncate(const char *filename);
943
946 static bool truncate(const char *filename, off64_t length);
947
948
961 static char *getContents(const char *name);
962
973 static ssize_t getContents(const char *name,
974 unsigned char *buffer,
975 size_t buffersize);
976
977
979 static bool exists(const char *filename);
980
983 static bool readable(const char *filename);
984
987 static bool writeable(const char *filename);
988
991 static bool executable(const char *filename);
992
1001 static bool accessible(const char *filename, int32_t mode);
1002
1008 static bool getLastChangeTime(const char *filename,
1009 time_t *ctime);
1010
1013 static bool setPermissions(const char *filename,
1014 mode_t perms);
1015
1018 static bool changeOwner(const char *filename,
1019 const char *newuser,
1020 const char *newgroup);
1021
1024 static bool changeOwner(const char *filename,
1025 uid_t uid, gid_t gid);
1026
1029 static bool canChangeOwner(const char *filename);
1030
1031
1035 static bool setLastAccessTime(const char *filename,
1036 time_t lastaccesstime);
1037
1041 static bool setLastModificationTime(const char *filename,
1042 time_t lastmodtime);
1043
1048 static bool setLastAccessAndModificationTimes(
1049 const char *filename,
1050 time_t lastaccesstime,
1051 time_t lastmodtime);
1052
1056 static bool setLastAccessAndModificationTimes(
1057 const char *filename);
1058
1059
1064 static char *dirname(const char *filename);
1065
1069 static char *basename(const char *filename);
1070
1076 static char *basename(const char *filename,
1077 const char *suffix);
1078
1084 static char *eightDotThree(const char *filename);
1085
1086
1092 static key_t generateKey(const char *filename, int32_t id);
1093
1096 static int64_t maxLinks(const char *filename);
1097
1098 #include <rudiments/private/file.h>
1099 };
1100
1101 #endif
file
Definition: file.h:21
filedescriptor::operator=
filedescriptor & operator=(const filedescriptor &f)
filedescriptor
Definition: filedescriptor.h:14