-
Notifications
You must be signed in to change notification settings - Fork 71
/
dir.h
80 lines (66 loc) · 2.43 KB
/
dir.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
* @author Amin Tahmasebi
* @date 2024
* @class Dir
*/
#ifndef DIR_H_
#define DIR_H_
#include <stdint.h>
#include "../vector/vector.h"
#ifdef __cplusplus
extern "C" {
#endif
// #define DIR_LOGGING_ENABLE
#ifdef DIR_LOGGING_ENABLE
#define DIR_LOG(fmt, ...) \
do { fprintf(stderr, "[DIR LOG] " fmt "\n", ##__VA_ARGS__); } while (0)
#else
#define DIR_LOG(fmt, ...) do { } while (0)
#endif
typedef bool (*DirCompareFunc)(const char* filePath, void* userData);
typedef enum {
DIR_LIST_FILES,
DIR_LIST_DIRECTORIES,
DIR_LIST_ALL
} DirListOption;
typedef enum {
DIR_FILE_TYPE_UNKNOWN,
DIR_FILE_TYPE_REGULAR,
DIR_FILE_TYPE_DIRECTORY,
DIR_FILE_TYPE_SYMLINK
} DirFileType;
bool dir_make_directory(const char* dirpath);
bool dir_cd(const char* dirName);
bool dir_cd_up();
bool dir_is_empty(const char* dirName);
bool dir_remove_directory(const char* dirName);
bool dir_remove_directory_recursive(const char* dirPath);
bool dir_rename(const char* oldName, const char* newName);
bool dir_is_directory_exists(const char* dirPath);
bool dir_is_file_exists(const char* filePath);
bool dir_copy_file(const char* srcPath, const char* destPath);
bool dir_copy_directory(const char* srcDir, const char* destDir);
bool dir_is_file(const char* filePath);
bool dir_is_directory(const char* filePath);
bool dir_move_file(const char* srcPath, const char* destPath);
bool dir_move_directory(const char* srcPath, const char* destPath);
bool dir_encrypt_file(const char* filePath, const char* password, uint8_t* iv);
bool dir_decrypt_file(const char* filePath, const char* password, uint8_t* iv);
bool dir_get_file_owner(const char* filePath, char* ownerBuffer, size_t bufferSize);
bool dir_get_directory_owner(const char* dirPath, char* ownerBuffer, size_t bufferSize);
bool dir_search(const char* dirPath, const char* pattern, DirCompareFunc callback, void* userData);
char* dir_get_creation_time(const char* dirPath);
char* dir_get_modified_time(const char* dirPath);
char* dir_dir_name(const char* dirpath);
char* dir_current_path(void);
char* dir_absolute_file_path(const char* relative_path);
char* dir_get_home_directory();
int dir_count(const char* dirpath);
void dir_list_contents(const char* dirPath, DirListOption option, Vector* result);
DirFileType dir_get_file_type(const char* filePath);
long long dir_get_directory_size(const char* dirPath);
long long dir_get_file_size(const char* filePath);
#ifdef __cplusplus
}
#endif
#endif