4 #ifndef RUDIMENTS_FILE_H
5 #define RUDIMENTS_FILE_H
7 #include <rudiments/private/fileincludes.h>
9 #ifdef RUDIMENTS_NAMESPACE
44 bool open(
const char *name, int32_t flags);
50 bool open(
const char *name, int32_t flags, mode_t perms);
55 bool create(
const char *name, mode_t perms);
61 ssize_t create(
const char *name, mode_t perms, uint16_t number);
67 ssize_t create(
const char *name, mode_t perms,
68 unsigned long number);
74 ssize_t create(
const char *name, mode_t perms,
float number);
80 ssize_t create(
const char *name, mode_t perms,
double number);
86 ssize_t create(
const char *name, mode_t perms,
char number);
92 ssize_t create(
const char *name, mode_t perms,
100 ssize_t create(
const char *name, mode_t perms,
101 const char *
string,
size_t size);
108 ssize_t create(
const char *name, mode_t perms,
109 const void *data,
size_t size);
130 ssize_t getContents(
unsigned char *buffer,
size_t buffersize);
136 bool truncate()
const;
141 bool truncate(off64_t length)
const;
147 off64_t getCurrentPosition()
const;
152 off64_t setPositionRelativeToBeginning(off64_t offset)
const;
157 off64_t setPositionRelativeToCurrent(off64_t offset)
const;
166 off64_t setPositionRelativeToEnd(off64_t offset)
const;
171 bool tryLockFile(int16_t type)
const;
177 bool lockFile(int16_t type)
const;
193 bool checkLockFile(int16_t type,
197 off64_t *conflen)
const;
201 bool unlockFile()
const;
208 bool tryLockRegion(int16_t type, off64_t start,
216 bool lockRegion(int16_t type, off64_t start,
234 bool checkLockRegion(int16_t type,
240 off64_t *conflen)
const;
246 bool unlockRegion(off64_t start, off64_t len)
const;
252 bool tryLockFromCurrent(int16_t type, off64_t len)
const;
259 bool tryLockFromCurrent(int16_t type, off64_t start,
267 bool lockFromCurrent(int16_t type, off64_t len)
const;
274 bool lockFromCurrent(int16_t type, off64_t start,
291 bool checkLockFromCurrent(int16_t type, off64_t len,
295 off64_t *conflen)
const;
312 bool checkLockFromCurrent(int16_t type, off64_t start,
317 off64_t *conflen)
const;
322 bool unlockFromCurrent(off64_t len)
const;
328 bool unlockFromCurrent(off64_t start, off64_t len)
const;
334 bool tryLockFromEnd(int16_t type, off64_t len)
const;
341 bool tryLockFromEnd(int16_t type, off64_t start,
349 bool lockFromEnd(int16_t type, off64_t len)
const;
356 bool lockFromEnd(int16_t type, off64_t start,
373 bool checkLockFromEnd(int16_t type, off64_t len,
377 off64_t *conflen)
const;
394 bool checkLockFromEnd(int16_t type, off64_t start,
399 off64_t *conflen)
const;
404 bool unlockFromEnd(off64_t len)
const;
410 bool unlockFromEnd(off64_t start, off64_t len)
const;
417 bool tryLockRemainder(int16_t type, off64_t start)
const;
424 bool lockRemainder(int16_t type, off64_t start)
const;
441 bool checkLockRemainder(int16_t type, off64_t start,
445 off64_t *conflen)
const;
451 bool unlockRemainder(off64_t start)
const;
457 bool tryLockRemainderFromCurrent(int16_t type)
const;
463 bool tryLockRemainderFromCurrent(int16_t type,
464 off64_t start)
const;
470 bool lockRemainderFromCurrent(int16_t type)
const;
477 bool lockRemainderFromCurrent(int16_t type,
478 off64_t start)
const;
494 bool checkLockRemainderFromCurrent(int16_t type,
498 off64_t *conflen)
const;
515 bool checkLockRemainderFromCurrent(int16_t type,
520 off64_t *conflen)
const;
525 bool unlockRemainderFromCurrent()
const;
531 bool unlockRemainderFromCurrent(off64_t start)
const;
537 bool tryLockRemainderFromEnd(int16_t type)
const;
543 bool tryLockRemainderFromEnd(int16_t type,
544 off64_t start)
const;
550 bool lockRemainderFromEnd(int16_t type)
const;
556 bool lockRemainderFromEnd(int16_t type, off64_t start)
const;
572 bool checkLockRemainderFromEnd(int16_t type,
576 off64_t *conflen)
const;
592 bool checkLockRemainderFromEnd(int16_t type,
597 off64_t *conflen)
const;
602 bool unlockRemainderFromEnd()
const;
607 bool unlockRemainderFromEnd(off64_t start)
const;
619 bool sequentialAccess(off64_t start,
size_t len)
const;
630 bool randomAccess(off64_t start,
size_t len)
const;
641 bool onlyOnce(off64_t start,
size_t len)
const;
652 bool willNeed(off64_t start,
size_t len)
const;
663 bool wontNeed(off64_t start,
size_t len)
const;
674 bool normalAccess(off64_t start,
size_t len)
const;
684 bool reserve(off64_t start,
size_t len)
const;
716 bool dataSync()
const;
723 void dontGetCurrentPropertiesOnOpen();
734 void getCurrentPropertiesOnOpen();
740 bool getCurrentProperties();
743 mode_t getPermissions()
const;
746 uid_t getOwnerUserId()
const;
749 gid_t getOwnerGroupId()
const;
752 off64_t getSize()
const;
757 blksize_t getBlockSize()
const;
761 blkcnt_t getBlockCount()
const;
765 int32_t isSocket()
const;
769 int32_t isSymbolicLink()
const;
773 int32_t isRegularFile()
const;
777 int32_t isBlockDevice()
const;
781 int32_t isDirectory()
const;
784 int32_t isCharacterDevice()
const;
788 int32_t isFifo()
const;
791 time_t getLastAccessTime()
const;
797 time_t getLastModificationTime()
const;
803 time_t getLastChangeTime()
const;
806 dev_t getDevice()
const;
809 dev_t getDeviceType()
const;
812 ino_t getInode()
const;
815 nlink_t getNumberOfHardLinks()
const;
820 bool changeOwner(
const char *newuser,
821 const char *newgroup)
const;
825 bool changeOwner(uid_t uid, gid_t gid)
const;
829 bool changeOwnerUser(
const char *newuser)
const;
833 bool changeOwnerUser(uid_t uid)
const;
837 bool changeOwnerGroup(
const char *newgroup)
const;
841 bool changeOwnerGroup(gid_t gid)
const;
846 bool canChangeOwner()
const;
850 long maxLinks()
const;
858 const char *
const *listAttributes()
const;
863 bool getAttribute(
const char *name,
864 uint16_t *number)
const;
868 bool getAttribute(
const char *name,
869 unsigned long *number)
const;
873 bool getAttribute(
const char *name, int16_t *number)
const;
877 bool getAttribute(
const char *name,
long *number)
const;
881 bool getAttribute(
const char *name,
float *number)
const;
885 bool getAttribute(
const char *name,
double *number)
const;
889 bool getAttribute(
const char *name,
894 bool getAttribute(
const char *name,
char *character)
const;
898 bool getAttribute(
const char *name,
bool *value)
const;
904 bool getAttribute(
const char *name,
905 unsigned char **
string)
const;
911 bool getAttribute(
const char *name,
912 char **
string)
const;
919 bool getAttribute(
const char *name,
920 unsigned char **
string,
928 bool getAttribute(
const char *name,
929 char **
string,
size_t *size)
const;
936 bool getAttribute(
const char *name,
937 void **buffer,
size_t *size)
const;
942 bool createAttribute(
const char *name,
943 uint16_t number)
const;
947 bool createAttribute(
const char *name,
948 unsigned long number)
const;
952 bool createAttribute(
const char *name, int16_t number)
const;
956 bool createAttribute(
const char *name,
long number)
const;
960 bool createAttribute(
const char *name,
float number)
const;
964 bool createAttribute(
const char *name,
double number)
const;
968 bool createAttribute(
const char *name,
969 unsigned char character)
const;
973 bool createAttribute(
const char *name,
char character)
const;
977 bool createAttribute(
const char *name,
bool value)
const;
981 bool createAttribute(
const char *name,
982 const unsigned char *
string)
const;
986 bool createAttribute(
const char *name,
987 const char *
string)
const;
992 bool createAttribute(
const char *name,
993 const unsigned char *
string,
999 bool createAttribute(
const char *name,
1000 const char *
string,
size_t size)
const;
1005 bool createAttribute(
const char *name,
1006 const void *buffer,
size_t size)
const;
1012 bool replaceAttribute(
const char *name,
1013 uint16_t number)
const;
1018 bool replaceAttribute(
const char *name,
1019 unsigned long number)
const;
1024 bool replaceAttribute(
const char *name,
1025 int16_t number)
const;
1030 bool replaceAttribute(
const char *name,
long number)
const;
1035 bool replaceAttribute(
const char *name,
float number)
const;
1040 bool replaceAttribute(
const char *name,
double number)
const;
1045 bool replaceAttribute(
const char *name,
1046 unsigned char character)
const;
1051 bool replaceAttribute(
const char *name,
1052 char character)
const;
1057 bool replaceAttribute(
const char *name,
bool value)
const;
1062 bool replaceAttribute(
const char *name,
1063 const unsigned char *
string)
const;
1068 bool replaceAttribute(
const char *name,
1069 const char *
string)
const;
1074 bool replaceAttribute(
const char *name,
1075 const unsigned char *
string,
1081 bool replaceAttribute(
const char *name,
1088 bool replaceAttribute(
const char *name,
1096 bool setAttribute(
const char *name,
1097 uint16_t number)
const;
1102 bool setAttribute(
const char *name,
1103 unsigned long number)
const;
1108 bool setAttribute(
const char *name, int16_t number)
const;
1113 bool setAttribute(
const char *name,
long number)
const;
1118 bool setAttribute(
const char *name,
float number)
const;
1123 bool setAttribute(
const char *name,
double number)
const;
1128 bool setAttribute(
const char *name,
1129 unsigned char character)
const;
1134 bool setAttribute(
const char *name,
char character)
const;
1139 bool setAttribute(
const char *name,
bool value)
const;
1144 bool setAttribute(
const char *name,
1145 const unsigned char *
string)
const;
1150 bool setAttribute(
const char *name,
1151 const char *
string)
const;
1157 bool setAttribute(
const char *name,
1158 const unsigned char *
string,
1165 bool setAttribute(
const char *name,
1173 bool setAttribute(
const char *name,
1180 bool removeAttribute(
const char *name)
const;
1184 void *getInternalFileStatisticsStructure();
1190 static bool createFile(
const char *name, mode_t perms);
1197 static ssize_t createFile(
const char *name,
1206 static ssize_t createFile(
const char *name,
1208 unsigned long number);
1215 static ssize_t createFile(
const char *name,
1224 static ssize_t createFile(
const char *name,
1233 static ssize_t createFile(
const char *name,
1242 static ssize_t createFile(
const char *name,
1244 const char *
string);
1251 static ssize_t createFile(
const char *name,
1261 static ssize_t createFile(
const char *name,
1269 static bool createFifo(
const char *filename, mode_t perms);
1284 static int32_t createTemporaryFile(
char *templatefilename);
1288 static bool createHardLink(
const char *oldpath,
1289 const char *newpath);
1294 static bool createSymbolicLink(
const char *oldpath,
1295 const char *newpath);
1303 static char *resolveSymbolicLink(
const char *filename);
1308 static bool rename(
const char *oldpath,
1309 const char *newpath);
1313 static bool remove(
const char *filename);
1318 static bool truncate(
const char *filename);
1322 static bool truncate(
const char *filename, off64_t length);
1334 static char *getContents(
const char *name);
1343 static ssize_t getContents(
const char *name,
1344 unsigned char *buffer,
1349 static bool exists(
const char *filename);
1353 static bool readable(
const char *filename);
1357 static bool writeable(
const char *filename);
1361 static bool executable(
const char *filename);
1371 static bool accessible(
const char *filename, int32_t mode);
1376 static bool getPermissions(
const char *filename,
1381 static bool getOwnerUserId(
const char *filename,
1386 static bool getOwnerGroupId(
const char *filename,
1391 static bool getSize(
const char *filename,
1397 static bool getBlockSize(
const char *filename,
1403 static bool getBlockCount(
const char *filename,
1408 static int32_t isSocket(
const char *filename);
1412 static int32_t isSymbolicLink(
const char *filename);
1416 static int32_t isRegularFile(
const char *filename);
1420 static int32_t isBlockDevice(
const char *filename);
1424 static int32_t isDirectory(
const char *filename);
1428 static int32_t isCharacterDevice(
const char *filename);
1432 static int32_t isFifo(
const char *filename);
1436 static bool getLastAccessTime(
const char *filename,
1444 static bool getLastModificationTime(
const char *filename,
1452 static bool getLastChangeTime(
const char *filename,
1457 static bool getDevice(
const char *filename, dev_t *dev);
1461 static bool getDeviceType(
const char *filename,
1466 static bool getInode(
const char *filename, ino_t *inode);
1470 static bool getNumberOfHardLinks(
const char *filename,
1475 static bool changeOwner(
const char *filename,
1476 const char *newuser,
1477 const char *newgroup);
1481 static bool changeOwner(
const char *filename,
1482 uid_t uid, gid_t gid);
1486 static bool changeOwnerUser(
const char *filename,
1487 const char *newuser);
1491 static bool changeOwnerUser(
const char *filename,
1496 static bool changeOwnerGroup(
const char *filename,
1497 const char *newgroup);
1501 static bool changeOwnerGroup(
const char *filename,
1506 static bool canChangeOwner(
const char *filename);
1512 static bool setLastAccessTime(
const char *filename,
1513 time_t lastaccesstime);
1518 static bool setLastModificationTime(
const char *filename,
1519 time_t lastmodtime);
1525 static bool setLastAccessAndModificationTimes(
1526 const char *filename,
1527 time_t lastaccesstime,
1528 time_t lastmodtime);
1533 static bool setLastAccessAndModificationTimes(
1534 const char *filename);
1541 static char *dirname(
const char *filename);
1546 static char *basename(
const char *filename);
1553 static char *basename(
const char *filename,
1554 const char *suffix);
1562 static key_t generateKey(
const char *filename, int32_t
id);
1566 static long maxLinks(
const char *filename);
1568 #include <rudiments/private/file.h>
1571 #ifdef RUDIMENTS_NAMESPACE