4 #ifndef RUDIMENTS_FILE_H
5 #define RUDIMENTS_FILE_H
7 #include <rudiments/private/fileincludes.h>
40 bool open(
const char *name, int32_t flags);
46 bool open(
const char *name, int32_t flags, mode_t perms);
51 bool create(
const char *name, mode_t perms);
71 ssize_t getContents(
unsigned char *buffer,
size_t buffersize);
77 bool truncate()
const;
82 bool truncate(off64_t length)
const;
88 off64_t getCurrentPosition()
const;
93 off64_t setPositionRelativeToBeginning(off64_t offset)
const;
98 off64_t setPositionRelativeToCurrent(off64_t offset)
const;
107 off64_t setPositionRelativeToEnd(off64_t offset)
const;
112 bool tryLockFile(int16_t type)
const;
118 bool lockFile(int16_t type)
const;
134 bool checkLockFile(int16_t type,
138 off64_t *conflen)
const;
142 bool unlockFile()
const;
149 bool tryLockRegion(int16_t type, off64_t start,
157 bool lockRegion(int16_t type, off64_t start,
175 bool checkLockRegion(int16_t type,
181 off64_t *conflen)
const;
187 bool unlockRegion(off64_t start, off64_t len)
const;
193 bool tryLockFromCurrent(int16_t type, off64_t len)
const;
200 bool tryLockFromCurrent(int16_t type, off64_t start,
208 bool lockFromCurrent(int16_t type, off64_t len)
const;
215 bool lockFromCurrent(int16_t type, off64_t start,
232 bool checkLockFromCurrent(int16_t type, off64_t len,
236 off64_t *conflen)
const;
253 bool checkLockFromCurrent(int16_t type, off64_t start,
258 off64_t *conflen)
const;
263 bool unlockFromCurrent(off64_t len)
const;
269 bool unlockFromCurrent(off64_t start, off64_t len)
const;
275 bool tryLockFromEnd(int16_t type, off64_t len)
const;
282 bool tryLockFromEnd(int16_t type, off64_t start,
290 bool lockFromEnd(int16_t type, off64_t len)
const;
297 bool lockFromEnd(int16_t type, off64_t start,
314 bool checkLockFromEnd(int16_t type, off64_t len,
318 off64_t *conflen)
const;
335 bool checkLockFromEnd(int16_t type, off64_t start,
340 off64_t *conflen)
const;
345 bool unlockFromEnd(off64_t len)
const;
351 bool unlockFromEnd(off64_t start, off64_t len)
const;
358 bool tryLockRemainder(int16_t type, off64_t start)
const;
365 bool lockRemainder(int16_t type, off64_t start)
const;
382 bool checkLockRemainder(int16_t type, off64_t start,
386 off64_t *conflen)
const;
392 bool unlockRemainder(off64_t start)
const;
398 bool tryLockRemainderFromCurrent(int16_t type)
const;
404 bool tryLockRemainderFromCurrent(int16_t type,
405 off64_t start)
const;
411 bool lockRemainderFromCurrent(int16_t type)
const;
418 bool lockRemainderFromCurrent(int16_t type,
419 off64_t start)
const;
435 bool checkLockRemainderFromCurrent(int16_t type,
439 off64_t *conflen)
const;
456 bool checkLockRemainderFromCurrent(int16_t type,
461 off64_t *conflen)
const;
466 bool unlockRemainderFromCurrent()
const;
472 bool unlockRemainderFromCurrent(off64_t start)
const;
478 bool tryLockRemainderFromEnd(int16_t type)
const;
484 bool tryLockRemainderFromEnd(int16_t type,
485 off64_t start)
const;
491 bool lockRemainderFromEnd(int16_t type)
const;
497 bool lockRemainderFromEnd(int16_t type, off64_t start)
const;
513 bool checkLockRemainderFromEnd(int16_t type,
517 off64_t *conflen)
const;
533 bool checkLockRemainderFromEnd(int16_t type,
538 off64_t *conflen)
const;
543 bool unlockRemainderFromEnd()
const;
548 bool unlockRemainderFromEnd(off64_t start)
const;
560 bool sequentialAccess(off64_t start,
size_t len)
const;
571 bool randomAccess(off64_t start,
size_t len)
const;
582 bool onlyOnce(off64_t start,
size_t len)
const;
593 bool willNeed(off64_t start,
size_t len)
const;
604 bool wontNeed(off64_t start,
size_t len)
const;
615 bool normalAccess(off64_t start,
size_t len)
const;
625 bool reserve(off64_t start,
size_t len)
const;
657 bool dataSync()
const;
664 void dontGetCurrentPropertiesOnOpen();
675 void getCurrentPropertiesOnOpen();
681 bool getCurrentProperties();
684 mode_t getPermissions()
const;
687 uid_t getOwnerUserId()
const;
690 gid_t getOwnerGroupId()
const;
693 off64_t getSize()
const;
698 blksize_t getBlockSize()
const;
702 blkcnt_t getBlockCount()
const;
706 int32_t isSocket()
const;
710 int32_t isSymbolicLink()
const;
714 int32_t isRegularFile()
const;
718 int32_t isBlockDevice()
const;
722 int32_t isDirectory()
const;
725 int32_t isCharacterDevice()
const;
729 int32_t isFifo()
const;
732 time_t getLastAccessTime()
const;
738 time_t getLastModificationTime()
const;
744 time_t getLastChangeTime()
const;
747 dev_t getDevice()
const;
750 dev_t getDeviceType()
const;
753 uint64_t getInode()
const;
756 nlink_t getNumberOfHardLinks()
const;
761 bool changeOwner(
const char *newuser,
762 const char *newgroup)
const;
766 bool changeOwner(uid_t uid, gid_t gid)
const;
771 bool canChangeOwner()
const;
775 int64_t maxLinks()
const;
780 void *getInternalFileStatisticsStructure();
786 static bool createFile(
const char *name, mode_t perms);
790 static bool createFifo(
const char *filename, mode_t perms);
805 static int32_t createTemporaryFile(
char *templatefilename);
809 static bool createHardLink(
const char *oldpath,
810 const char *newpath);
815 static bool createSymbolicLink(
const char *oldpath,
816 const char *newpath);
824 static char *resolveSymbolicLink(
const char *filename);
829 static bool rename(
const char *oldpath,
830 const char *newpath);
834 static bool remove(
const char *filename);
839 static bool truncate(
const char *filename);
843 static bool truncate(
const char *filename, off64_t length);
855 static char *getContents(
const char *name);
864 static ssize_t getContents(
const char *name,
865 unsigned char *buffer,
870 static bool exists(
const char *filename);
874 static bool readable(
const char *filename);
878 static bool writeable(
const char *filename);
882 static bool executable(
const char *filename);
892 static bool accessible(
const char *filename, int32_t mode);
899 static bool getLastChangeTime(
const char *filename,
904 static bool changeOwner(
const char *filename,
906 const char *newgroup);
910 static bool changeOwner(
const char *filename,
911 uid_t uid, gid_t gid);
915 static bool canChangeOwner(
const char *filename);
921 static bool setLastAccessTime(
const char *filename,
922 time_t lastaccesstime);
927 static bool setLastModificationTime(
const char *filename,
934 static bool setLastAccessAndModificationTimes(
935 const char *filename,
936 time_t lastaccesstime,
942 static bool setLastAccessAndModificationTimes(
943 const char *filename);
950 static char *dirname(
const char *filename);
955 static char *basename(
const char *filename);
962 static char *basename(
const char *filename,
970 static char *eightDotThree(
const char *filename);
978 static key_t generateKey(
const char *filename, int32_t
id);
982 static int64_t maxLinks(
const char *filename);
984 #include <rudiments/private/file.h>
filedescriptor & operator=(const filedescriptor &f)
Definition: filedescriptor.h:14