1 #ifndef R_FILE_H
2 #define R_FILE_H
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 #include <r_util/r_mem.h>
9 
10 /* is */
11 R_API bool r_file_is_abspath(const char *file);
12 R_API bool r_file_is_c(const char *file);
13 R_API bool r_file_is_directory(const char *str);
14 R_API bool r_file_is_regular(const char *str);
15 
16 R_API bool r_file_truncate(const char *filename, ut64 newsize);
17 R_API char *r_file_new(const char *root, ...);
18 R_API ut64 r_file_size(const char *str);
19 R_API char *r_file_root(const char *root, const char *path);
20 R_API RMmap *r_file_mmap(const char *file, bool rw, ut64 base);
21 R_API int r_file_mmap_read(const char *file, ut64 addr, ut8 *buf, int len);
22 R_API int r_file_mmap_write(const char *file, ut64 addr, const ut8 *buf, int len);
23 R_API void r_file_mmap_free(RMmap *m);
24 R_API bool r_file_chmod(const char *file, const char *mod, int recursive);
25 R_API char *r_file_temp(const char *prefix);
26 R_API char *r_file_path(const char *bin);
27 R_API const char *r_file_basename(const char *path);
28 R_API char *r_file_dirname(const char *path);
29 R_API char *r_file_abspath_rel(const char *cwd, const char *file);
30 R_API char *r_file_abspath(const char *file);
31 R_API ut8 *r_inflate(const ut8 *src, int srcLen, int *srcConsumed, int *dstLen);
32 R_API ut8 *r_file_gzslurp(const char *str, int *outlen, int origonfail);
33 R_API char *r_stdin_slurp(int *sz);
34 R_API char *r_file_slurp(const char *str, R_NULLABLE size_t *usz);
35 //R_API char *r_file_slurp_range(const char *str, ut64 off, ut64 sz);
36 R_API char *r_file_slurp_range(const char *str, ut64 off, int sz, int *osz);
37 R_API char *r_file_slurp_random_line(const char *file);
38 R_API char *r_file_slurp_random_line_count(const char *file, int *linecount);
39 R_API ut8 *r_file_slurp_hexpairs(const char *str, int *usz);
40 R_API bool r_file_dump(const char *file, const ut8 *buf, int len, bool append);
41 R_API bool r_file_touch(const char *file);
42 R_API bool r_file_hexdump(const char *file, const ut8 *buf, int len, int append);
43 R_API bool r_file_rm(const char *file);
44 R_API bool r_file_exists(const char *str);
45 R_API bool r_file_fexists(const char *fmt, ...) R_PRINTF_CHECK(1, 2);
46 R_API char *r_file_slurp_line(const char *file, int line, int context);
47 R_API char *r_file_slurp_lines(const char *file, int line, int count);
48 R_API char *r_file_slurp_lines_from_bottom(const char *file, int line);
49 R_API int r_file_mkstemp(const char *prefix, char **oname);
50 R_API char *r_file_tmpdir(void);
51 R_API char *r_file_readlink(const char *path);
52 R_API bool r_file_copy(const char *src, const char *dst);
53 R_API bool r_file_move(const char *src, const char *dst);
54 R_API RList* r_file_globsearch (const char *globbed_path, int maxdepth);
55 R_API RMmap *r_file_mmap_arch (RMmap *map, const char *filename, int fd);
56 
57 #ifdef __cplusplus
58 }
59 #endif
60 
61 #endif //  R_FILE_H
62