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;
783 const char *
const *listAttributes()
const;
788 bool getAttribute(
const char *name, uint16_t *number)
const;
792 bool getAttribute(
const char *name, uint32_t *number)
const;
796 bool getAttribute(
const char *name, uint64_t *number)
const;
800 bool getAttribute(
const char *name, int16_t *number)
const;
804 bool getAttribute(
const char *name, int32_t *number)
const;
808 bool getAttribute(
const char *name, int64_t *number)
const;
812 bool getAttribute(
const char *name,
float *number)
const;
816 bool getAttribute(
const char *name,
double *number)
const;
820 bool getAttribute(
const char *name,
825 bool getAttribute(
const char *name,
char *character)
const;
829 bool getAttribute(
const char *name,
bool *value)
const;
835 bool getAttribute(
const char *name,
836 unsigned char **
string)
const;
842 bool getAttribute(
const char *name,
843 char **
string)
const;
850 bool getAttribute(
const char *name,
851 unsigned char **
string,
859 bool getAttribute(
const char *name,
860 char **
string,
size_t *size)
const;
867 bool getAttribute(
const char *name,
868 void **buffer,
size_t *size)
const;
873 bool getAttribute(
const char *name,
874 void *buffer,
size_t size)
const;
879 bool createAttribute(
const char *name,
880 uint16_t number)
const;
884 bool createAttribute(
const char *name,
885 uint32_t number)
const;
889 bool createAttribute(
const char *name,
890 uint64_t number)
const;
894 bool createAttribute(
const char *name, int16_t number)
const;
898 bool createAttribute(
const char *name, int32_t number)
const;
902 bool createAttribute(
const char *name, int64_t number)
const;
906 bool createAttribute(
const char *name,
float number)
const;
910 bool createAttribute(
const char *name,
double number)
const;
914 bool createAttribute(
const char *name,
915 unsigned char character)
const;
919 bool createAttribute(
const char *name,
char character)
const;
923 bool createAttribute(
const char *name,
bool value)
const;
927 bool createAttribute(
const char *name,
928 const unsigned char *
string)
const;
932 bool createAttribute(
const char *name,
933 const char *
string)
const;
938 bool createAttribute(
const char *name,
939 const unsigned char *
string,
945 bool createAttribute(
const char *name,
946 const char *
string,
size_t size)
const;
951 bool createAttribute(
const char *name,
952 const void *buffer,
size_t size)
const;
958 bool replaceAttribute(
const char *name,
959 uint16_t number)
const;
964 bool replaceAttribute(
const char *name,
965 uint32_t number)
const;
970 bool replaceAttribute(
const char *name,
971 uint64_t number)
const;
976 bool replaceAttribute(
const char *name,
977 int16_t number)
const;
982 bool replaceAttribute(
const char *name,
983 int32_t number)
const;
988 bool replaceAttribute(
const char *name,
989 int64_t number)
const;
994 bool replaceAttribute(
const char *name,
float number)
const;
999 bool replaceAttribute(
const char *name,
double number)
const;
1004 bool replaceAttribute(
const char *name,
1005 unsigned char character)
const;
1010 bool replaceAttribute(
const char *name,
1011 char character)
const;
1016 bool replaceAttribute(
const char *name,
bool value)
const;
1021 bool replaceAttribute(
const char *name,
1022 const unsigned char *
string)
const;
1027 bool replaceAttribute(
const char *name,
1028 const char *
string)
const;
1033 bool replaceAttribute(
const char *name,
1034 const unsigned char *
string,
1040 bool replaceAttribute(
const char *name,
1047 bool replaceAttribute(
const char *name,
1055 bool setAttribute(
const char *name,
1056 uint16_t number)
const;
1061 bool setAttribute(
const char *name,
1062 uint32_t number)
const;
1067 bool setAttribute(
const char *name,
1068 uint64_t number)
const;
1073 bool setAttribute(
const char *name, int16_t number)
const;
1078 bool setAttribute(
const char *name, int32_t number)
const;
1083 bool setAttribute(
const char *name, int64_t number)
const;
1088 bool setAttribute(
const char *name,
float number)
const;
1093 bool setAttribute(
const char *name,
double number)
const;
1098 bool setAttribute(
const char *name,
1099 unsigned char character)
const;
1104 bool setAttribute(
const char *name,
char character)
const;
1109 bool setAttribute(
const char *name,
bool value)
const;
1114 bool setAttribute(
const char *name,
1115 const unsigned char *
string)
const;
1120 bool setAttribute(
const char *name,
1121 const char *
string)
const;
1127 bool setAttribute(
const char *name,
1128 const unsigned char *
string,
1135 bool setAttribute(
const char *name,
1143 bool setAttribute(
const char *name,
1150 bool removeAttribute(
const char *name)
const;
1154 void *getInternalFileStatisticsStructure();
1159 static bool createFile(
const char *name, mode_t perms);
1163 static bool createFifo(
const char *filename, mode_t perms);
1178 static int32_t createTemporaryFile(
char *templatefilename);
1182 static bool createHardLink(
const char *oldpath,
1183 const char *newpath);
1188 static bool createSymbolicLink(
const char *oldpath,
1189 const char *newpath);
1197 static char *resolveSymbolicLink(
const char *filename);
1202 static bool rename(
const char *oldpath,
1203 const char *newpath);
1207 static bool remove(
const char *filename);
1212 static bool truncate(
const char *filename);
1216 static bool truncate(
const char *filename, off64_t length);
1228 static char *getContents(
const char *name);
1237 static ssize_t getContents(
const char *name,
1238 unsigned char *buffer,
1243 static bool exists(
const char *filename);
1247 static bool readable(
const char *filename);
1251 static bool writeable(
const char *filename);
1255 static bool executable(
const char *filename);
1265 static bool accessible(
const char *filename, int32_t mode);
1272 static bool getLastChangeTime(
const char *filename,
1277 static bool changeOwner(
const char *filename,
1278 const char *newuser,
1279 const char *newgroup);
1283 static bool changeOwner(
const char *filename,
1284 uid_t uid, gid_t gid);
1288 static bool canChangeOwner(
const char *filename);
1294 static bool setLastAccessTime(
const char *filename,
1295 time_t lastaccesstime);
1300 static bool setLastModificationTime(
const char *filename,
1301 time_t lastmodtime);
1307 static bool setLastAccessAndModificationTimes(
1308 const char *filename,
1309 time_t lastaccesstime,
1310 time_t lastmodtime);
1315 static bool setLastAccessAndModificationTimes(
1316 const char *filename);
1323 static char *dirname(
const char *filename);
1328 static char *basename(
const char *filename);
1335 static char *basename(
const char *filename,
1336 const char *suffix);
1343 static char *eightDotThree(
const char *filename);
1351 static key_t generateKey(
const char *filename, int32_t
id);
1355 static int64_t maxLinks(
const char *filename);
1357 #include <rudiments/private/file.h>