File
Ioto provides some simple helper functions to read and write files.
To read a file in one go:
ssize size;
char *data = rReadFile("file.txt", &size);
To write a file:
ssize length = rWriteFile("file.txt", data, dataLen, 0644);
To get the current working directory:
char dir = rGetCwd();
To get the base directory containing the application executable:
char dir = rGetAppDir();
To join two file paths:
PUBLIC char *rJoinFile(cchar *base, cchar *other);
To matach a file against a glob pattern. This tests a filename against a file pattern that list may contain the wildcards: "?" Matches any single character, "*" matches zero or more characters of the file or directory and "**"/ matches zero or more directories
if (rMatchFile("file.text", "*.txt")) {
// Matches
}
To get a list of files in a directory or subdirectories that match the given wildcard pattern.
RList *list = rGetFiles("/somedir", "*.txt", 0);
To walk a directory tree and invoke a callback for each path that matches a given pattern.
rWalkDir("/dir", "*.txt", fn, arg, 0);
To get a temporary filename:
char *path = rGetTempFile("/tmp", "TEMP-");
This returns a temporary filename in /tmp starting with the "TEMP-" prefix.