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
19class RUDIMENTS_DLLSPEC file : public filedescriptor {
20 public:
21
24
26 virtual ~file();
27
52 virtual bool open(const char *name, int32_t flags);
53
85 virtual bool open(const char *name,
86 int32_t flags,
87 mode_t perms);
88
97 virtual bool create(const char *name, mode_t perms);
98
99
111 virtual char *getContents();
112
123 virtual ssize_t getContents(byte_t *buffer,
124 size_t buffersize);
125
137 virtual ssize_t getContents(byte_t **buffer,
138 size_t *buffersize);
139
143 virtual bool truncate();
144
148 virtual bool truncate(off64_t size);
149
150
154 virtual bool tryLockFile(int16_t type);
155
160 virtual bool lockFile(int16_t type);
161
176 virtual bool checkLockFile(int16_t type,
177 int16_t *conftype,
178 int16_t *confwhence,
179 off64_t *confstart,
180 off64_t *conflen);
181
184 virtual bool unlockFile();
185
191 virtual bool tryLockRegion(int16_t type,
192 off64_t start,
193 off64_t len);
194
200 virtual bool lockRegion(int16_t type,
201 off64_t start,
202 off64_t len);
203
219 virtual bool checkLockRegion(int16_t type,
220 off64_t start,
221 off64_t len,
222 int16_t *conftype,
223 int16_t *confwhence,
224 off64_t *confstart,
225 off64_t *conflen);
226
231 virtual bool unlockRegion(off64_t start,
232 off64_t len);
233
238 virtual bool tryLockFromCurrent(int16_t type,
239 off64_t len);
240
246 virtual bool tryLockFromCurrent(int16_t type,
247 off64_t start,
248 off64_t len);
249
255 virtual bool lockFromCurrent(int16_t type,
256 off64_t len);
257
263 virtual bool lockFromCurrent(int16_t type,
264 off64_t start,
265 off64_t len);
266
281 virtual bool checkLockFromCurrent(int16_t type,
282 off64_t len,
283 int16_t *conftype,
284 int16_t *confwhence,
285 off64_t *confstart,
286 off64_t *conflen);
287
303 virtual bool checkLockFromCurrent(int16_t type,
304 off64_t start,
305 off64_t len,
306 int16_t *conftype,
307 int16_t *confwhence,
308 off64_t *confstart,
309 off64_t *conflen);
310
314 virtual bool unlockFromCurrent(off64_t len);
315
320 virtual bool unlockFromCurrent(off64_t start,
321 off64_t len);
322
327 virtual bool tryLockFromEnd(int16_t type,
328 off64_t len);
329
335 virtual bool tryLockFromEnd(int16_t type,
336 off64_t start,
337 off64_t len);
338
344 virtual bool lockFromEnd(int16_t type, off64_t len);
345
351 virtual bool lockFromEnd(int16_t type,
352 off64_t start,
353 off64_t len);
354
369 virtual bool checkLockFromEnd(int16_t type,
370 off64_t len,
371 int16_t *conftype,
372 int16_t *confwhence,
373 off64_t *confstart,
374 off64_t *conflen);
375
391 virtual bool checkLockFromEnd(int16_t type,
392 off64_t start,
393 off64_t len,
394 int16_t *conftype,
395 int16_t *confwhence,
396 off64_t *confstart,
397 off64_t *conflen);
398
402 virtual bool unlockFromEnd(off64_t len);
403
408 virtual bool unlockFromEnd(off64_t start,
409 off64_t len);
410
416 virtual bool tryLockRemainder(int16_t type,
417 off64_t start);
418
424 virtual bool lockRemainder(int16_t type,
425 off64_t start);
426
442 virtual bool checkLockRemainder(int16_t type,
443 off64_t start,
444 int16_t *conftype,
445 int16_t *confwhence,
446 off64_t *confstart,
447 off64_t *conflen);
448
453 virtual bool unlockRemainder(off64_t start);
454
459 virtual bool tryLockRemainderFromCurrent(int16_t type);
460
465 virtual bool tryLockRemainderFromCurrent(int16_t type,
466 off64_t start);
467
472 virtual bool lockRemainderFromCurrent(int16_t type);
473
479 virtual bool lockRemainderFromCurrent(int16_t type,
480 off64_t start);
481
497 int16_t type,
498 int16_t *conftype,
499 int16_t *confwhence,
500 off64_t *confstart,
501 off64_t *conflen);
502
519 int16_t type,
520 off64_t start,
521 int16_t *conftype,
522 int16_t *confwhence,
523 off64_t *confstart,
524 off64_t *conflen);
525
530
535 virtual bool unlockRemainderFromCurrent(off64_t start);
536
541 virtual bool tryLockRemainderFromEnd(int16_t type);
542
547 virtual bool tryLockRemainderFromEnd(int16_t type,
548 off64_t start);
549
554 virtual bool lockRemainderFromEnd(int16_t type);
555
560 virtual bool lockRemainderFromEnd(int16_t type,
561 off64_t start);
562
578 int16_t type,
579 int16_t *conftype,
580 int16_t *confwhence,
581 off64_t *confstart,
582 off64_t *conflen);
583
599 int16_t type,
600 off64_t start,
601 int16_t *conftype,
602 int16_t *confwhence,
603 off64_t *confstart,
604 off64_t *conflen);
605
610
614 virtual bool unlockRemainderFromEnd(off64_t start);
615
616
626 virtual bool adviseSequentialAccess(off64_t start,
627 size_t len);
628
638 virtual bool adviseRandomAccess(off64_t start, size_t len);
639
649 virtual bool adviseOnlyOnce(off64_t start, size_t len);
650
660 virtual bool adviseWillNeed(off64_t start, size_t len);
661
671 virtual bool adviseWontNeed(off64_t start, size_t len);
672
682 virtual bool adviseNormalAccess(off64_t start, size_t len);
683
684
692 virtual bool reserve(off64_t start, size_t len);
693
694
707 virtual bool sync();
708
724 virtual bool syncData();
725
726
742 virtual void setGetCurrentPropertiesOnOpen(bool set);
743
748 virtual bool getCurrentProperties();
749
751 virtual mode_t getPermissions();
752
754 virtual uid_t getOwnerUserId();
755
757 virtual gid_t getOwnerGroupId();
758
760 virtual off64_t getSize();
761
765 virtual blksize_t getBlockSize();
766
769 virtual blkcnt_t getBlockCount();
770
773 virtual int32_t isSocket();
774
777 virtual int32_t isSymbolicLink();
778
781 virtual int32_t isRegularFile();
782
785 virtual int32_t isBlockDevice();
786
789 virtual int32_t isDirectory();
790
793 virtual int32_t isCharacterDevice();
794
797 virtual int32_t isFifo();
798
800 virtual time_t getLastAccessTime();
801
806 virtual time_t getLastModificationTime();
807
812 virtual time_t getLastChangeTime();
813
815 virtual dev_t getDevice();
816
818 virtual dev_t getDeviceType();
819
821 virtual uint64_t getInode();
822
824 virtual nlink_t getNumberOfHardLinks();
825
826
829 virtual bool setPermissions(mode_t perms);
830
831
834 virtual bool changeOwner(const char *newuser,
835 const char *newgroup);
836
839 virtual bool changeOwner(uid_t uid, gid_t gid);
840
844 virtual bool getCanChangeOwner();
845
848 virtual int64_t getMaxLinks();
849
850
854
855
859 static bool createFile(const char *name, mode_t perms);
860
863 static bool createFifo(const char *filename, mode_t perms);
864
873 static int32_t createTemporaryFile(char *templatefilename);
874
887 static int32_t createTemporaryFile(char *templatefilename,
888 mode_t perms);
889
892 static bool createHardLink(const char *oldpath,
893 const char *newpath);
894
898 static bool createSymbolicLink(const char *oldpath,
899 const char *newpath);
900
907 static char *resolveSymbolicLink(const char *filename);
908
909
912 static bool rename(const char *oldpath,
913 const char *newpath);
914
917 static bool remove(const char *filename);
918
919
922 static bool truncate(const char *filename);
923
926 static bool truncate(const char *filename, off64_t size);
927
928
941 static char *getContents(const char *name);
942
953 static ssize_t getContents(const char *name,
954 byte_t *buffer,
955 size_t buffersize);
956
967 virtual ssize_t getContents(const char *name,
968 byte_t **buffer,
969 size_t *buffersize);
970
971
973 static bool exists(const char *filename);
974
977 static bool isReadable(const char *filename);
978
981 static bool isWriteable(const char *filename);
982
985 static bool isExecutable(const char *filename);
986
995 static bool isAccessible(const char *filename,
996 int32_t mode);
997
1003 static bool getLastChangeTime(const char *filename,
1004 time_t *ctime);
1005
1008 static bool setPermissions(const char *filename,
1009 mode_t perms);
1010
1013 static bool changeOwner(const char *filename,
1014 const char *newuser,
1015 const char *newgroup);
1016
1019 static bool changeOwner(const char *filename,
1020 uid_t uid, gid_t gid);
1021
1024 static bool getCanChangeOwner(const char *filename);
1025
1026
1030 static bool setLastAccessTime(const char *filename,
1031 time_t lastaccesstime);
1032
1036 static bool setLastModificationTime(const char *filename,
1037 time_t lastmodtime);
1038
1044 const char *filename,
1045 time_t lastaccesstime,
1046 time_t lastmodtime);
1047
1052 const char *filename);
1053
1054
1059 static char *getDirName(const char *filename);
1060
1064 static char *getBaseName(const char *filename);
1065
1071 static char *getBaseName(const char *filename,
1072 const char *ext);
1073
1078 static char *getExtension(const char *filename);
1079
1085 static char *getEightDotThree(const char *filename);
1086
1087
1093 static key_t generateKey(const char *filename, int32_t id);
1094
1097 static int64_t getMaxLinks(const char *filename);
1098
1110 const char *pattern,
1111 linkedlist<char *> *matches);
1112
1125 const char * const *patterns,
1126 linkedlist<char *> *matches);
1127
1139 linkedlist<const char *> *patterns,
1140 linkedlist<char *> *matches);
1141
1153 linkedlist<char *> *patterns,
1154 linkedlist<char *> *matches);
1155
1156 #include <rudiments/private/file.h>
1157};
1158
1159#endif
Definition file.h:19
static char * getDirName(const char *filename)
static bool isWriteable(const char *filename)
static char * getEightDotThree(const char *filename)
static bool createSymbolicLink(const char *oldpath, const char *newpath)
virtual time_t getLastAccessTime()
static bool remove(const char *filename)
virtual bool open(const char *name, int32_t flags)
virtual int32_t isBlockDevice()
static bool isAccessible(const char *filename, int32_t mode)
static char * getBaseName(const char *filename, const char *ext)
virtual bool unlockFromEnd(off64_t start, off64_t len)
virtual bool tryLockFromCurrent(int16_t type, off64_t len)
virtual bool tryLockRemainderFromEnd(int16_t type)
virtual bool tryLockRemainderFromCurrent(int16_t type, off64_t start)
virtual bool getCurrentProperties()
static char * resolveSymbolicLink(const char *filename)
virtual bool tryLockFromEnd(int16_t type, off64_t start, off64_t len)
virtual bool adviseOnlyOnce(off64_t start, size_t len)
static bool createFile(const char *name, mode_t perms)
virtual int32_t isSymbolicLink()
virtual blksize_t getBlockSize()
static ssize_t getContents(const char *name, byte_t *buffer, size_t buffersize)
virtual off64_t getSize()
virtual ssize_t getContents(byte_t **buffer, size_t *buffersize)
static char * getExtension(const char *filename)
virtual bool sync()
virtual bool setPermissions(mode_t perms)
virtual bool lockFromEnd(int16_t type, off64_t start, off64_t len)
virtual int32_t isDirectory()
static bool setLastAccessAndModificationTimes(const char *filename)
virtual int32_t isCharacterDevice()
virtual bool tryLockFile(int16_t type)
static key_t generateKey(const char *filename, int32_t id)
virtual bool unlockRemainder(off64_t start)
virtual void setGetCurrentPropertiesOnOpen(bool set)
virtual bool reserve(off64_t start, size_t len)
virtual int32_t isRegularFile()
virtual bool checkLockRemainderFromCurrent(int16_t type, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
virtual int64_t getMaxLinks()
virtual blkcnt_t getBlockCount()
static char * getBaseName(const char *filename)
virtual bool unlockRemainderFromEnd(off64_t start)
virtual ~file()
virtual bool adviseNormalAccess(off64_t start, size_t len)
virtual bool adviseWillNeed(off64_t start, size_t len)
static bool setLastAccessTime(const char *filename, time_t lastaccesstime)
virtual bool checkLockRemainderFromEnd(int16_t type, off64_t start, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
virtual uid_t getOwnerUserId()
virtual bool lockRemainder(int16_t type, off64_t start)
virtual bool lockRemainderFromEnd(int16_t type)
virtual bool lockRemainderFromEnd(int16_t type, off64_t start)
static bool createHardLink(const char *oldpath, const char *newpath)
static char * getContents(const char *name)
virtual bool lockRemainderFromCurrent(int16_t type)
virtual bool tryLockRemainder(int16_t type, off64_t start)
static int32_t createTemporaryFile(char *templatefilename)
static bool getCanChangeOwner(const char *filename)
static bool getMatchingFileNames(const char *pattern, linkedlist< char * > *matches)
virtual bool lockFromCurrent(int16_t type, off64_t start, off64_t len)
static bool getMatchingFileNames(linkedlist< const char * > *patterns, linkedlist< char * > *matches)
virtual bool unlockRegion(off64_t start, off64_t len)
static bool setLastModificationTime(const char *filename, time_t lastmodtime)
virtual bool checkLockRemainder(int16_t type, off64_t start, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
virtual bool unlockFile()
virtual bool create(const char *name, mode_t perms)
static int64_t getMaxLinks(const char *filename)
virtual bool changeOwner(uid_t uid, gid_t gid)
static bool truncate(const char *filename)
virtual bool truncate()
virtual time_t getLastChangeTime()
virtual bool getCanChangeOwner()
virtual int32_t isSocket()
static bool rename(const char *oldpath, const char *newpath)
static bool getLastChangeTime(const char *filename, time_t *ctime)
virtual mode_t getPermissions()
virtual bool checkLockRegion(int16_t type, off64_t start, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
static bool changeOwner(const char *filename, uid_t uid, gid_t gid)
virtual bool checkLockFromEnd(int16_t type, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
static bool setPermissions(const char *filename, mode_t perms)
virtual bool checkLockFile(int16_t type, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
virtual int32_t isFifo()
virtual nlink_t getNumberOfHardLinks()
virtual bool checkLockFromCurrent(int16_t type, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
virtual bool syncData()
virtual bool checkLockRemainderFromEnd(int16_t type, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
virtual bool lockFile(int16_t type)
virtual dev_t getDevice()
virtual ssize_t getContents(byte_t *buffer, size_t buffersize)
virtual bool adviseSequentialAccess(off64_t start, size_t len)
virtual bool truncate(off64_t size)
virtual bool adviseWontNeed(off64_t start, size_t len)
virtual bool tryLockFromCurrent(int16_t type, off64_t start, off64_t len)
virtual bool checkLockFromCurrent(int16_t type, off64_t start, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
virtual bool changeOwner(const char *newuser, const char *newgroup)
virtual bool unlockFromEnd(off64_t len)
virtual bool tryLockFromEnd(int16_t type, off64_t len)
virtual void * getInternalFileStatisticsStructure()
virtual bool lockRegion(int16_t type, off64_t start, off64_t len)
virtual bool lockRemainderFromCurrent(int16_t type, off64_t start)
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 bool tryLockRemainderFromCurrent(int16_t type)
virtual bool lockFromEnd(int16_t type, off64_t len)
virtual bool adviseRandomAccess(off64_t start, size_t len)
virtual bool unlockFromCurrent(off64_t start, off64_t len)
virtual bool unlockFromCurrent(off64_t len)
virtual bool unlockRemainderFromCurrent()
virtual bool unlockRemainderFromCurrent(off64_t start)
virtual char * getContents()
static bool exists(const char *filename)
static bool isReadable(const char *filename)
virtual time_t getLastModificationTime()
virtual bool lockFromCurrent(int16_t type, off64_t len)
virtual ssize_t getContents(const char *name, byte_t **buffer, size_t *buffersize)
static bool createFifo(const char *filename, mode_t perms)
static bool isExecutable(const char *filename)
static int32_t createTemporaryFile(char *templatefilename, mode_t perms)
static bool getMatchingFileNames(linkedlist< char * > *patterns, linkedlist< char * > *matches)
virtual bool checkLockRemainderFromCurrent(int16_t type, off64_t start, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
virtual gid_t getOwnerGroupId()
static bool truncate(const char *filename, off64_t size)
virtual bool unlockRemainderFromEnd()
static bool setLastAccessAndModificationTimes(const char *filename, time_t lastaccesstime, time_t lastmodtime)
static bool getMatchingFileNames(const char *const *patterns, linkedlist< char * > *matches)
virtual bool tryLockRegion(int16_t type, off64_t start, off64_t len)
virtual uint64_t getInode()
virtual dev_t getDeviceType()
virtual bool tryLockRemainderFromEnd(int16_t type, off64_t start)
virtual bool checkLockFromEnd(int16_t type, off64_t start, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
Definition filedescriptor.h:13
Definition linkedlist.h:47