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 bool open(const char *name, int32_t flags);
64
93 bool open(const char *name, int32_t flags, mode_t perms);
94
101 bool create(const char *name, mode_t perms);
102
103
113 char *getContents();
114
122 ssize_t getContents(unsigned char *buffer,size_t buffersize);
123
124
128 bool truncate() const;
129
133 bool truncate(off64_t length) const;
134
135
139 off64_t getCurrentPosition() const;
140
144 off64_t setPositionRelativeToBeginning(off64_t offset) const;
145
149 off64_t setPositionRelativeToCurrent(off64_t offset) const;
150
158 off64_t setPositionRelativeToEnd(off64_t offset) const;
159
163 bool tryLockFile(int16_t type) const;
164
169 bool lockFile(int16_t type) const;
170
185 bool checkLockFile(int16_t type,
186 int16_t *conftype,
187 int16_t *confwhence,
188 off64_t *confstart,
189 off64_t *conflen) const;
190
193 bool unlockFile() const;
194
200 bool tryLockRegion(int16_t type, off64_t start,
201 off64_t len) const;
202
208 bool lockRegion(int16_t type, off64_t start,
209 off64_t len) const;
210
226 bool checkLockRegion(int16_t type,
227 off64_t start,
228 off64_t len,
229 int16_t *conftype,
230 int16_t *confwhence,
231 off64_t *confstart,
232 off64_t *conflen) const;
233
238 bool unlockRegion(off64_t start, off64_t len) const;
239
244 bool tryLockFromCurrent(int16_t type, off64_t len) const;
245
251 bool tryLockFromCurrent(int16_t type, off64_t start,
252 off64_t len) const;
253
259 bool lockFromCurrent(int16_t type, off64_t len) const;
260
266 bool lockFromCurrent(int16_t type, off64_t start,
267 off64_t len) const;
268
283 bool checkLockFromCurrent(int16_t type, off64_t len,
284 int16_t *conftype,
285 int16_t *confwhence,
286 off64_t *confstart,
287 off64_t *conflen) const;
288
304 bool checkLockFromCurrent(int16_t type, off64_t start,
305 off64_t len,
306 int16_t *conftype,
307 int16_t *confwhence,
308 off64_t *confstart,
309 off64_t *conflen) const;
310
314 bool unlockFromCurrent(off64_t len) const;
315
320 bool unlockFromCurrent(off64_t start, off64_t len) const;
321
326 bool tryLockFromEnd(int16_t type, off64_t len) const;
327
333 bool tryLockFromEnd(int16_t type, off64_t start,
334 off64_t len) const;
335
341 bool lockFromEnd(int16_t type, off64_t len) const;
342
348 bool lockFromEnd(int16_t type, off64_t start,
349 off64_t len) const;
350
365 bool checkLockFromEnd(int16_t type, off64_t len,
366 int16_t *conftype,
367 int16_t *confwhence,
368 off64_t *confstart,
369 off64_t *conflen) const;
370
386 bool checkLockFromEnd(int16_t type, off64_t start,
387 off64_t len,
388 int16_t *conftype,
389 int16_t *confwhence,
390 off64_t *confstart,
391 off64_t *conflen) const;
392
396 bool unlockFromEnd(off64_t len) const;
397
402 bool unlockFromEnd(off64_t start, off64_t len) const;
403
409 bool tryLockRemainder(int16_t type, off64_t start) const;
410
416 bool lockRemainder(int16_t type, off64_t start) const;
417
433 bool checkLockRemainder(int16_t type, off64_t start,
434 int16_t *conftype,
435 int16_t *confwhence,
436 off64_t *confstart,
437 off64_t *conflen) const;
438
443 bool unlockRemainder(off64_t start) const;
444
449 bool tryLockRemainderFromCurrent(int16_t type) const;
450
455 bool tryLockRemainderFromCurrent(int16_t type,
456 off64_t start) const;
457
462 bool lockRemainderFromCurrent(int16_t type) const;
463
469 bool lockRemainderFromCurrent(int16_t type,
470 off64_t start) const;
471
486 bool checkLockRemainderFromCurrent(int16_t type,
487 int16_t *conftype,
488 int16_t *confwhence,
489 off64_t *confstart,
490 off64_t *conflen) const;
491
507 bool checkLockRemainderFromCurrent(int16_t type,
508 off64_t start,
509 int16_t *conftype,
510 int16_t *confwhence,
511 off64_t *confstart,
512 off64_t *conflen) const;
513
517 bool unlockRemainderFromCurrent() const;
518
523 bool unlockRemainderFromCurrent(off64_t start) const;
524
529 bool tryLockRemainderFromEnd(int16_t type) const;
530
535 bool tryLockRemainderFromEnd(int16_t type,
536 off64_t start) const;
537
542 bool lockRemainderFromEnd(int16_t type) const;
543
548 bool lockRemainderFromEnd(int16_t type, off64_t start) const;
549
564 bool checkLockRemainderFromEnd(int16_t type,
565 int16_t *conftype,
566 int16_t *confwhence,
567 off64_t *confstart,
568 off64_t *conflen) const;
569
584 bool checkLockRemainderFromEnd(int16_t type,
585 off64_t start,
586 int16_t *conftype,
587 int16_t *confwhence,
588 off64_t *confstart,
589 off64_t *conflen) const;
590
594 bool unlockRemainderFromEnd() const;
595
599 bool unlockRemainderFromEnd(off64_t start) const;
600
601
611 bool sequentialAccess(off64_t start, size_t len) const;
612
622 bool randomAccess(off64_t start, size_t len) const;
623
633 bool onlyOnce(off64_t start, size_t len) const;
634
644 bool willNeed(off64_t start, size_t len) const;
645
655 bool wontNeed(off64_t start, size_t len) const;
656
666 bool normalAccess(off64_t start, size_t len) const;
667
668
676 bool reserve(off64_t start, size_t len) const;
677
678
691 bool sync() const;
692
708 bool dataSync() const;
709
710
715 void dontGetCurrentPropertiesOnOpen();
716
726 void getCurrentPropertiesOnOpen();
727
732 bool getCurrentProperties();
733
735 mode_t getPermissions() const;
736
738 uid_t getOwnerUserId() const;
739
741 gid_t getOwnerGroupId() const;
742
744 off64_t getSize() const;
745
749 blksize_t getBlockSize() const;
750
753 blkcnt_t getBlockCount() const;
754
757 int32_t isSocket() const;
758
761 int32_t isSymbolicLink() const;
762
765 int32_t isRegularFile() const;
766
769 int32_t isBlockDevice() const;
770
773 int32_t isDirectory() const;
776 int32_t isCharacterDevice() const;
777
780 int32_t isFifo() const;
781
783 time_t getLastAccessTime() const;
784
789 time_t getLastModificationTime() const;
790
795 time_t getLastChangeTime() const;
796
798 dev_t getDevice() const;
799
801 dev_t getDeviceType() const;
802
804 uint64_t getInode() const;
805
807 nlink_t getNumberOfHardLinks() const;
808
809
812 bool setPermissions(mode_t perms) const;
813
814
817 bool changeOwner(const char *newuser,
818 const char *newgroup) const;
819
822 bool changeOwner(uid_t uid, gid_t gid) const;
823
827 bool canChangeOwner() const;
828
831 int64_t maxLinks() const;
832
833
836 void *getInternalFileStatisticsStructure();
837
838
842 static bool createFile(const char *name, mode_t perms);
843
846 static bool createFifo(const char *filename, mode_t perms);
847
850 static bool createPipe(filedescriptor *readfd,
851 filedescriptor *writefd);
852
861 static int32_t createTemporaryFile(char *templatefilename);
862
865 static bool createHardLink(const char *oldpath,
866 const char *newpath);
867
871 static bool createSymbolicLink(const char *oldpath,
872 const char *newpath);
873
880 static char *resolveSymbolicLink(const char *filename);
881
882
885 static bool rename(const char *oldpath,
886 const char *newpath);
887
890 static bool remove(const char *filename);
891
892
895 static bool truncate(const char *filename);
896
899 static bool truncate(const char *filename, off64_t length);
900
901
911 static char *getContents(const char *name);
912
920 static ssize_t getContents(const char *name,
921 unsigned char *buffer,
922 size_t buffersize);
923
924
926 static bool exists(const char *filename);
927
930 static bool readable(const char *filename);
931
934 static bool writeable(const char *filename);
935
938 static bool executable(const char *filename);
939
948 static bool accessible(const char *filename, int32_t mode);
949
955 static bool getLastChangeTime(const char *filename,
956 time_t *ctime);
957
960 static bool setPermissions(const char *filename,
961 mode_t perms);
962
965 static bool changeOwner(const char *filename,
966 const char *newuser,
967 const char *newgroup);
968
971 static bool changeOwner(const char *filename,
972 uid_t uid, gid_t gid);
973
976 static bool canChangeOwner(const char *filename);
977
978
982 static bool setLastAccessTime(const char *filename,
983 time_t lastaccesstime);
984
988 static bool setLastModificationTime(const char *filename,
989 time_t lastmodtime);
990
995 static bool setLastAccessAndModificationTimes(
996 const char *filename,
997 time_t lastaccesstime,
998 time_t lastmodtime);
999
1003 static bool setLastAccessAndModificationTimes(
1004 const char *filename);
1005
1006
1011 static char *dirname(const char *filename);
1012
1016 static char *basename(const char *filename);
1017
1023 static char *basename(const char *filename,
1024 const char *suffix);
1025
1031 static char *eightDotThree(const char *filename);
1032
1033
1039 static key_t generateKey(const char *filename, int32_t id);
1040
1043 static int64_t maxLinks(const char *filename);
1044
1045 #include <rudiments/private/file.h>
1046 };
1047
1048 #endif
file
Definition: file.h:21
filedescriptor::operator=
filedescriptor & operator=(const filedescriptor &f)
filedescriptor
Definition: filedescriptor.h:14