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

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
150 virtual off64_t setPositionRelativeToBeginning(
151 off64_t offset) const;
152
156 virtual off64_t setPositionRelativeToCurrent(
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
513 virtual bool checkLockRemainderFromCurrent(
514 int16_t type,
515 int16_t *conftype,
516 int16_t *confwhence,
517 off64_t *confstart,
518 off64_t *conflen) const;
519
535 virtual bool checkLockRemainderFromCurrent(
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
594 virtual bool checkLockRemainderFromEnd(
595 int16_t type,
596 int16_t *conftype,
597 int16_t *confwhence,
598 off64_t *confstart,
599 off64_t *conflen) const;
600
615 virtual bool checkLockRemainderFromEnd(
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
748 virtual void dontGetCurrentPropertiesOnOpen();
749
759 virtual void getCurrentPropertiesOnOpen();
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
870 virtual void *getInternalFileStatisticsStructure();
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
1045 static bool setLastAccessAndModificationTimes(
1046 const char *filename,
1047 time_t lastaccesstime,
1048 time_t lastmodtime);
1049
1053 static bool setLastAccessAndModificationTimes(
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
file
Definition: file.h:19
file::unlockFromCurrent
virtual bool unlockFromCurrent(off64_t len) const
file::unlockRemainderFromEnd
virtual bool unlockRemainderFromEnd() const
file::checkLockRemainderFromCurrent
virtual bool checkLockRemainderFromCurrent(int16_t type, off64_t start, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
file::createSymbolicLink
static bool createSymbolicLink(const char *oldpath, const char *newpath)
file::canChangeOwner
static bool canChangeOwner(const char *filename)
file::remove
static bool remove(const char *filename)
file::tryLockRemainderFromEnd
virtual bool tryLockRemainderFromEnd(int16_t type) const
file::open
virtual bool open(const char *name, int32_t flags)
file::getLastChangeTime
virtual time_t getLastChangeTime() const
file::getDeviceType
virtual dev_t getDeviceType() const
file::lockRemainderFromEnd
virtual bool lockRemainderFromEnd(int16_t type) const
file::willNeed
virtual bool willNeed(off64_t start, size_t len) const
file::unlockFromEnd
virtual bool unlockFromEnd(off64_t len) const
file::onlyOnce
virtual bool onlyOnce(off64_t start, size_t len) const
file::unlockRemainderFromCurrent
virtual bool unlockRemainderFromCurrent(off64_t start) const
file::isBlockDevice
virtual int32_t isBlockDevice() const
file::getCurrentProperties
virtual bool getCurrentProperties()
file::file
file()
file::sync
virtual bool sync() const
file::createFile
static bool createFile(const char *name, mode_t perms)
file::getLastModificationTime
virtual time_t getLastModificationTime() const
file::lockFromEnd
virtual bool lockFromEnd(int16_t type, off64_t start, off64_t len) const
file::unlockFile
virtual bool unlockFile() const
file::tryLockFile
virtual bool tryLockFile(int16_t type) const
file::getBlockCount
virtual blkcnt_t getBlockCount() const
file::getContents
static char * getContents(const char *name)
file::dirname
static char * dirname(const char *filename)
file::checkLockFromEnd
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
file::wontNeed
virtual bool wontNeed(off64_t start, size_t len) const
file::setLastAccessAndModificationTimes
static bool setLastAccessAndModificationTimes(const char *filename)
file::writeable
static bool writeable(const char *filename)
file::generateKey
static key_t generateKey(const char *filename, int32_t id)
file::checkLockFromCurrent
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
file::tryLockRemainder
virtual bool tryLockRemainder(int16_t type, off64_t start) const
file::randomAccess
virtual bool randomAccess(off64_t start, size_t len) const
file::isDirectory
virtual int32_t isDirectory() const
file::basename
static char * basename(const char *filename, const char *ext)
file::checkLockRemainderFromEnd
virtual bool checkLockRemainderFromEnd(int16_t type, off64_t start, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
file::getInode
virtual uint64_t getInode() const
file::checkLockFile
virtual bool checkLockFile(int16_t type, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
file::getBlockSize
virtual blksize_t getBlockSize() const
file::~file
virtual ~file()
file::getLastAccessTime
virtual time_t getLastAccessTime() const
file::setLastAccessTime
static bool setLastAccessTime(const char *filename, time_t lastaccesstime)
file::checkLockRemainder
virtual bool checkLockRemainder(int16_t type, off64_t start, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
file::tryLockRegion
virtual bool tryLockRegion(int16_t type, off64_t start, off64_t len) const
file::unlockRemainderFromEnd
virtual bool unlockRemainderFromEnd(off64_t start) const
file::setPositionRelativeToBeginning
virtual off64_t setPositionRelativeToBeginning(off64_t offset) const
file::createHardLink
static bool createHardLink(const char *oldpath, const char *newpath)
file::truncate
virtual bool truncate() const
file::executable
static bool executable(const char *filename)
file::createTemporaryFile
static int32_t createTemporaryFile(char *templatefilename)
file::checkLockRegion
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
file::getNumberOfHardLinks
virtual nlink_t getNumberOfHardLinks() const
file::tryLockFromEnd
virtual bool tryLockFromEnd(int16_t type, off64_t len) const
file::lockFromEnd
virtual bool lockFromEnd(int16_t type, off64_t len) const
file::setLastModificationTime
static bool setLastModificationTime(const char *filename, time_t lastmodtime)
file::isCharacterDevice
virtual int32_t isCharacterDevice() const
file::create
virtual bool create(const char *name, mode_t perms)
file::getCurrentPosition
virtual off64_t getCurrentPosition() const
file::isSymbolicLink
virtual int32_t isSymbolicLink() const
file::accessible
static bool accessible(const char *filename, int32_t mode)
file::resolveSymbolicLink
static char * resolveSymbolicLink(const char *filename)
file::isRegularFile
virtual int32_t isRegularFile() const
file::lockFile
virtual bool lockFile(int16_t type) const
file::isSocket
virtual int32_t isSocket() const
file::truncate
static bool truncate(const char *filename)
file::tryLockFromCurrent
virtual bool tryLockFromCurrent(int16_t type, off64_t len) const
file::readable
static bool readable(const char *filename)
file::dontGetCurrentPropertiesOnOpen
virtual void dontGetCurrentPropertiesOnOpen()
file::rename
static bool rename(const char *oldpath, const char *newpath)
file::getContents
virtual char * getContents()
file::lockRemainderFromCurrent
virtual bool lockRemainderFromCurrent(int16_t type) const
file::getLastChangeTime
static bool getLastChangeTime(const char *filename, time_t *ctime)
file::unlockFromEnd
virtual bool unlockFromEnd(off64_t start, off64_t len) const
file::changeOwner
virtual bool changeOwner(const char *newuser, const char *newgroup) const
file::changeOwner
static bool changeOwner(const char *filename, uid_t uid, gid_t gid)
file::getCurrentPropertiesOnOpen
virtual void getCurrentPropertiesOnOpen()
file::basename
static char * basename(const char *filename)
file::setPositionRelativeToCurrent
virtual off64_t setPositionRelativeToCurrent(off64_t offset) const
file::setPermissions
virtual bool setPermissions(mode_t perms) const
file::isFifo
virtual int32_t isFifo() const
file::sequentialAccess
virtual bool sequentialAccess(off64_t start, size_t len) const
file::setPermissions
static bool setPermissions(const char *filename, mode_t perms)
file::getPermissions
virtual mode_t getPermissions() const
file::operator=
file & operator=(const file &f)
file::unlockFromCurrent
virtual bool unlockFromCurrent(off64_t start, off64_t len) const
file::maxLinks
static int64_t maxLinks(const char *filename)
file::checkLockFromCurrent
virtual bool checkLockFromCurrent(int16_t type, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
file::tryLockFromEnd
virtual bool tryLockFromEnd(int16_t type, off64_t start, off64_t len) const
file::lockFromCurrent
virtual bool lockFromCurrent(int16_t type, off64_t start, off64_t len) const
file::setPositionRelativeToEnd
virtual off64_t setPositionRelativeToEnd(off64_t offset) const
file::tryLockRemainderFromEnd
virtual bool tryLockRemainderFromEnd(int16_t type, off64_t start) const
file::open
virtual bool open(const char *name, int32_t flags, mode_t perms)
file::changeOwner
static bool changeOwner(const char *filename, const char *newuser, const char *newgroup)
file::getSize
virtual off64_t getSize() const
file::lockRemainderFromEnd
virtual bool lockRemainderFromEnd(int16_t type, off64_t start) const
file::getOwnerUserId
virtual uid_t getOwnerUserId() const
file::getContents
virtual ssize_t getContents(unsigned char *buffer, size_t buffersize)
file::lockRegion
virtual bool lockRegion(int16_t type, off64_t start, off64_t len) const
file::file
file(const file &f)
file::normalAccess
virtual bool normalAccess(off64_t start, size_t len) const
file::lockRemainderFromCurrent
virtual bool lockRemainderFromCurrent(int16_t type, off64_t start) const
file::truncate
virtual bool truncate(off64_t size) const
file::exists
static bool exists(const char *filename)
file::unlockRemainder
virtual bool unlockRemainder(off64_t start) const
file::getInternalFileStatisticsStructure
virtual void * getInternalFileStatisticsStructure()
file::maxLinks
virtual int64_t maxLinks() const
file::dataSync
virtual bool dataSync() const
file::createFifo
static bool createFifo(const char *filename, mode_t perms)
file::changeOwner
virtual bool changeOwner(uid_t uid, gid_t gid) const
file::checkLockFromEnd
virtual bool checkLockFromEnd(int16_t type, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
file::tryLockRemainderFromCurrent
virtual bool tryLockRemainderFromCurrent(int16_t type, off64_t start) const
file::reserve
virtual bool reserve(off64_t start, size_t len) const
file::lockFromCurrent
virtual bool lockFromCurrent(int16_t type, off64_t len) const
file::createTemporaryFile
static int32_t createTemporaryFile(char *templatefilename, mode_t perms)
file::getContents
static ssize_t getContents(const char *name, unsigned char *buffer, size_t buffersize)
file::checkLockRemainderFromCurrent
virtual bool checkLockRemainderFromCurrent(int16_t type, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
file::eightDotThree
static char * eightDotThree(const char *filename)
file::getDevice
virtual dev_t getDevice() const
file::tryLockRemainderFromCurrent
virtual bool tryLockRemainderFromCurrent(int16_t type) const
file::extension
static char * extension(const char *filename)
file::lockRemainder
virtual bool lockRemainder(int16_t type, off64_t start) const
file::checkLockRemainderFromEnd
virtual bool checkLockRemainderFromEnd(int16_t type, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const
file::truncate
static bool truncate(const char *filename, off64_t size)
file::getOwnerGroupId
virtual gid_t getOwnerGroupId() const
file::tryLockFromCurrent
virtual bool tryLockFromCurrent(int16_t type, off64_t start, off64_t len) const
file::canChangeOwner
virtual bool canChangeOwner() const
file::setLastAccessAndModificationTimes
static bool setLastAccessAndModificationTimes(const char *filename, time_t lastaccesstime, time_t lastmodtime)
file::unlockRemainderFromCurrent
virtual bool unlockRemainderFromCurrent() const
file::unlockRegion
virtual bool unlockRegion(off64_t start, off64_t len) const
filedescriptor
Definition: filedescriptor.h:13