-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwrapper.h
154 lines (139 loc) · 5.46 KB
/
wrapper.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#ifndef WRAPPER_H
#define WRAPPER_H
#include <stdint.h>
/**
* @brief Dumps a directory recursively from CCOS disk image.
*
* @param[in] path The path to CCOS image.
* @param[in] dir The directory.
* @param[in] data CCOS image data.
*
* @return 0 on success, -1 otherwise.
*/
int dump_dir(const char* path, ccos_inode_t* dir, uint8_t* data);
/**
* @brief Dumps all files and directories from CCOS disk image.
*
* @param[in] path The path to CCOS image.
* @param[in] dir The directory.
* @param[in] data CCOS image data.
*
* @return 0 on success, -1 otherwise.
*/
int dump_image(const char* path, uint8_t* data, size_t data_size);
/**
* @brief Dumps file to directory from CCOS disk image.
*
* @param[in] path_to_dir The path to CCOS image.
* @param[in] file The file.
* @param[in] image_data CCOS image data.
*
* @return 0 on success, -1 otherwise.
*/
int dump_file(const char* path_to_dir, ccos_inode_t* file, uint8_t* image_data);
/**
* @brief Dumps a directory recursively from CCOS disk image to a custom folder.
*
* @param[in] path The path to CCOS image.
* @param[in] dir The directory.
* @param[in] data CCOS image data.
* @param[in] destpath The path to destination folder.
*
* @return 0 on success, -1 otherwise.
*/
int dump_dir_to(const char* path, ccos_inode_t* dir, uint8_t* data, const char* destpath);
/**
* @brief Dumps all files and directories from CCOS disk image to a custom folder.
*
* @param[in] path The path to CCOS image.
* @param[in] dir The directory.
* @param[in] data CCOS image data.
* @param[in] destpath The path to destination folder.
*
* @return 0 on success, -1 otherwise.
*/
int dump_image_to(const char* path, uint8_t* data, size_t data_size, const char* destpath);
/**
* @brief Prints a CCOS image contents.
*
* @param[in] path The path to CCOS image.
* @param[in] superblock The superblock inode.
* @param[in] data CCOS image data.
* @param[in] short_format Use shorter, 80-column compatible output format.
*
* @return 0 on success, -1 otherwise.
*/
int print_image_info(const char* path, uint8_t* data, size_t data_size, int short_format);
/**
* @brief Replace file in the CCOS image.
*
* @param[in] path Path to the CCOS image.
* @param[in] filename Path to the file to replace in the CCOS image.
* @param[in] target_name If given, then the file with this name will be replaced in the CCOS image. Otherwise,
* basename of the filename will be used.
* @param[in] superblock The superblock inode.
* @param data CCOS image data.
* @param[in] data_size CCOS image data size.
* @param[in] in_place Flag indicating whether to save replaced file under a new name (path.new), or overwrite the
* original file.
*
* @return 0 on success, -1 otherwise.
*/
int replace_file(const char* path, const char* filename, const char* target_name, uint8_t* data, size_t data_size,
int in_place);
/**
* @brief Copy file from one image into another.
*
* @param[in] target_image Path to the image to copy file to.
* @param[in] filename The name of file to copy.
* @param[in] superblock The superblock in the source image.
* @param[in] source_data CCOS source image data.
* @param[in] source_size CCOS source image data size.
* @param[in] in_place If true, override original target image. Otherwise, save new image under {target_image}.out
* name.
*
* @return 0 on success, -1 otherwise.
*/
int copy_file(const char* target_image, const char* filename, uint8_t* source_data, size_t source_size, int in_place);
/**
* @brief Delete file in the image.
*
* @param[in] path Path to the image to delete file in.
* @param[in] filename The name of file to delete.
* @param[in] in_place If true, override original target image. Otherwise, save new image under {target_image}.out
* name.
*
* @return 0 on success, -1 otherwise.
*/
int delete_file(const char* path, const char* filename, int in_place);
/**
* @brief Add file to the image.
*
* @param[in] image_path Path to the image to add file.
* @param[in] file_path The path to file to add.
* @param[in] file_name The name of file to delete.
* @param[in] data CCOS image data.
* @param[in] data_size CCOS image data size.
* @param[in] in_place If true, override original target image. Otherwise, save new image under {target_image}.out
* name.
*
* @return 0 on success, -1 otherwise.
*/
int add_file(const char* image_path, const char* file_path, const char* file_name, uint8_t* data, size_t data_size,
int in_place);
/**
* @brief Create directory in the image.
*
* @param[in] path Path to the image to create dir.
* @param[in] directory_name The name of file to delete.
* @param[in] file_contents CCOS image data.
* @param[in] file_size CCOS image data size.
* @param[in] in_place If true, override original target image. Otherwise, save new image under
* {target_image}.out name.
*
* @return 0 on success, -1 otherwise.
*/
int create_directory(char* path, char* directory_name, uint8_t* file_contents, size_t file_size, int in_place);
int rename_file(char* path, char* file_name, char* new_name, uint8_t* image_data, size_t image_size, int in_place);
int create_blank_image(char* path);
#endif // WRAPPER_H