regify utility 2.1.0-0
 
Loading...
Searching...
No Matches
io.h
1/*
2 * Copyright regify
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
29#ifndef REGIFY_UTIL_IO_H
30#define REGIFY_UTIL_IO_H
31#include <sys/types.h>
32#include <sys/stat.h>
33
34/* Only need to export C interface if used by C++ source code */
35#ifdef __cplusplus
36extern "C" {
37#endif /* __cplusplus */
38
44RUAPI bool ruFileExists(trans_chars filename);
45
53RUAPI bool ruIsFile(trans_chars filename);
54
62RUAPI bool ruIsDir(trans_chars filename);
63
74RUAPI bool ruIsExecutable(trans_chars filename);
75
76#ifndef _WIN32
82RUAPI bool ruIsSymlink(trans_chars filename);
83#endif
84
93RUAPI int32_t ruDiskFree(trans_chars path, uint64_t* total, uint64_t* avail);
94
98typedef struct stat ruStat_t;
99
111RUAPI int32_t ruStat(trans_chars filepath, ruStat_t *dest);
112
124RUAPI rusize ruFileSize(trans_chars filePath, int32_t* code);
125
137RUAPI sec_t ruFileUtcTime(trans_chars filePath, int32_t* code);
138
145RUAPI int32_t ruFileSetUtcTime(trans_chars filePath, sec_t date);
146
156RUAPI int ruOpen(trans_chars filepath, int flags, int mode, int32_t* code);
157
165RUAPI FILE* ruFOpen(trans_chars filepath, trans_chars mode, int32_t* code);
166
181RUAPI int ruOpenTmp(char *pathTemplate, int flags, int mode, int32_t *code);
182
190RUAPI rusize_s ruWrite(int oh, trans_ptr contents, rusize length);
191
203RUAPI int32_t ruFileSetContents(trans_chars filename, trans_chars contents, rusize length);
204
214RUAPI int ruFileGetContents(trans_chars filename, alloc_chars* contents, rusize* length);
215
222RUAPI int ruFileCopy(trans_chars srcpath, trans_chars destpath);
223
231RUAPI int ruFileRename(trans_chars oldName, trans_chars newName);
232
240RUAPI int ruFileTryRename(trans_chars oldName, trans_chars newName);
241
247RUAPI int ruFileRemove(trans_chars filename);
248
252#define RU_WALK_FOLDER_FIRST 0x1
256#define RU_WALK_FOLDER_LAST 0x2
260#define RU_WALK_NO_RECURSE 0x4
264#define RU_WALK_NO_SELF 0x8
269#define RU_WALK_UNIX_SLASHES 0x10
270
271
285typedef bool (*entryFilter) (trans_chars folderPath, trans_chars fileName, bool isFolder, ptr ctx);
286
295typedef int32_t (*entryMgr) (trans_chars fullPath, bool isFolder, ptr ctx);
296
309RUAPI int32_t ruFilteredFolderWalk(trans_chars folder, uint32_t flags,
310 entryFilter filter, entryMgr actor, ptr ctx);
311
322RUAPI int32_t ruFolderWalk(trans_chars folder, uint32_t flags, entryMgr actor, ptr ctx);
323
332
340RUAPI int32_t ruFolderRemove(trans_chars folder);
341
349RUAPI int32_t ruMkdir(trans_chars pathname, int mode, bool deep);
350
360
368
376
387
395
403
416RUAPI alloc_chars ruPathMultiJoin(int parts, ...);
417
430RUAPI alloc_chars ruPathMultiJoinNative(int parts, ...);
431
435#ifdef __cplusplus
436}
437#endif /* __cplusplus */
438#endif //REGIFY_UTIL_IO_H
RUAPI int32_t ruFilteredFolderWalk(trans_chars folder, uint32_t flags, entryFilter filter, entryMgr actor, ptr ctx)
Like ruFolderWalk with additional filtering capability. Folder entries . and .. are not passed to fil...
RUAPI int32_t ruFolderWalk(trans_chars folder, uint32_t flags, entryMgr actor, ptr ctx)
Decends into given folder depth first and calls actor on each entry. Folder entries ....
RUAPI ru_int ruFolderEntries(trans_chars folder)
Returns the number of folder entries including itself.
RUAPI int ruFileTryRename(trans_chars oldName, trans_chars newName)
Renames a given file like ruFileRename, but fails when newName already exists instead of overwriting ...
RUAPI int32_t ruStat(trans_chars filepath, ruStat_t *dest)
RUAPI int ruFileRename(trans_chars oldName, trans_chars newName)
RUAPI bool ruIsSymlink(trans_chars filename)
RUAPI FILE * ruFOpen(trans_chars filepath, trans_chars mode, int32_t *code)
RUAPI int ruFileCopy(trans_chars srcpath, trans_chars destpath)
Copies srcpath to destpath.
RUAPI bool ruIsDir(trans_chars filename)
RUAPI bool ruIsExecutable(trans_chars filename)
RUAPI bool ruIsFile(trans_chars filename)
RUAPI sec_t ruFileUtcTime(trans_chars filePath, int32_t *code)
Return the UTC modification date of the given file if it exists.
RUAPI rusize_s ruWrite(int oh, trans_ptr contents, rusize length)
RUAPI rusize ruFileSize(trans_chars filePath, int32_t *code)
Return the size of the given file if it exists.
RUAPI alloc_chars ruFullPath(trans_chars filePath)
Returns an absolute filepath leading to the given relative path.
RUAPI alloc_chars ruPathJoin(trans_chars base, trans_chars file)
Returns base and file joined with the a unix filesystem slash in a new string.
RUAPI int32_t ruFileSetContents(trans_chars filename, trans_chars contents, rusize length)
bool(* entryFilter)(trans_chars folderPath, trans_chars fileName, bool isFolder, ptr ctx)
A function that is called with each entry of a ruFolderWalk to decide whether that entry should be pr...
Definition io.h:285
RUAPI alloc_chars ruPathJoinNative(trans_chars base, trans_chars file)
Returns base and file joined with the filesystem slash in a new string.
RUAPI alloc_chars ruPathMultiJoin(int parts,...)
Return a path by concatenating the given parts number of parameters using a unix style directory slas...
RUAPI bool ruFileExists(trans_chars filename)
RUAPI int32_t ruFileSetUtcTime(trans_chars filePath, sec_t date)
Set UTC access and mod time of given filePath to given date.
RUAPI alloc_chars ruPathMultiJoinNative(int parts,...)
Return a path by concatenating the given parts number of parameters using the platform native directo...
RUAPI perm_chars ruBaseName(perm_chars filePath)
Returns the filename of a path with the preceding path removed.
RUAPI perm_chars ruFileExtension(perm_chars filePath)
Returns the extension part of the given file name if there is one.
RUAPI int32_t ruFolderRemove(trans_chars folder)
Recursively delete given folder and all it's sub contents. If given path is a file or symlink,...
RUAPI alloc_chars ruDirName(trans_chars filePath)
Returns the dirname part of a full path without the trailing slash.
RUAPI int ruOpen(trans_chars filepath, int flags, int mode, int32_t *code)
RUAPI int ruFileGetContents(trans_chars filename, alloc_chars *contents, rusize *length)
RUAPI int ruOpenTmp(char *pathTemplate, int flags, int mode, int32_t *code)
struct stat ruStat_t
Definition io.h:98
int32_t(* entryMgr)(trans_chars fullPath, bool isFolder, ptr ctx)
A function that is called with each entry of a ruFolderWalk.
Definition io.h:295
RUAPI int32_t ruDiskFree(trans_chars path, uint64_t *total, uint64_t *avail)
RUAPI int32_t ruMkdir(trans_chars pathname, int mode, bool deep)
RUAPI int ruFileRemove(trans_chars filename)
intptr_t ru_int
A pointer sized integer type for collections like ruMap or ruList.
Definition regify-util.h:328
const void * trans_ptr
A transient pointer.
Definition regify-util.h:287
const char * trans_chars
A transient NULL terminated string pointer.
Definition regify-util.h:186
const char * perm_chars
A permanent NULL terminated string pointer.
Definition regify-util.h:176
long sec_t
A signed type for expressing seconds.
Definition regify-util.h:312
char * alloc_chars
An allocated NULL terminated string pointer.
Definition regify-util.h:199
size_t rusize
Abstracted version of size_t.
Definition regify-util.h:338
void * ptr
A generic pointer.
Definition regify-util.h:304
signed long rusize_s
Abstracted version of size_t but signed.
Definition regify-util.h:152