MicrOS
micros_filesystem.h
Go to the documentation of this file.
1 #ifndef MICROS_FILESYSTEM_H
2 #define MICROS_FILESYSTEM_H
3 
4 #include <stdbool.h>
5 #include <stdint.h>
6 #include "micros_interrupts.h"
7 
9 typedef struct micros_filesystem_time
10 {
12  uint16_t year;
13 
15  uint8_t month;
16 
18  uint8_t day;
19 
21  uint8_t hour;
22 
24  uint8_t minutes;
25 
27  uint8_t seconds;
28 } __attribute__((packed)) micros_filesystem_time;
29 
32 {
34  char name[32];
35 
37  char path[256];
38 
41 
44 
47 
51 
54 {
56  char name[32];
57 
59  char path[256];
60 
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
70 
76 bool micros_filesystem_get_file_info(const char *path, micros_filesystem_file_info *file_info);
77 
78 
80 
86 bool micros_filesystem_get_directory_info(const char *path, micros_filesystem_directory_info *directory_info);
87 
89 
97 bool micros_filesystem_read_file(const char *path, uint8_t *buffer, const uint32_t start_index, const uint32_t length);
98 
100 
106 
108 
114 bool micros_filesystem_get_entries_in_directory(const char *path, char **entries);
115 
117 
122 bool micros_filesystem_is_file(const char *path);
123 
125 
130 bool micros_filesystem_is_directory(const char *path);
131 
133 
138 bool micros_filesystem_create_file(const char *path);
139 
141 
146 bool micros_filesystem_create_directory(const char *path);
147 
149 
154 bool micros_filesystem_delete_file(const char *path);
155 
157 
162 bool micros_filesystem_delete_directory(const char *path);
163 
165 
171 bool micros_filesystem_rename_file(const char *path, const char *new_name);
172 
174 
180 bool micros_filesystem_rename_directory(const char *path, const char *new_name);
181 
183 
190 bool micros_filesystem_save_to_file(const char *path, const char *buffer, const int size);
191 
193 
200 bool micros_filesystem_append_to_file(const char *path, const char *buffer, const int size);
201 
203 
208 bool micros_filesystem_file_exists(const char *path);
209 
211 
216 bool micros_filesystem_directory_exists(const char *path);
217 
219 
224 int micros_filesystem_get_free_space(const char partition_symbol);
225 
227 
232 int micros_filesystem_get_total_space(const char partition_symbol);
233 
234 #ifdef __cplusplus
235 }
236 #endif
237 
238 #endif
bool micros_filesystem_create_directory(const char *path)
Creates directory.
Definition: micros_filesystem.c:43
int micros_filesystem_get_free_space(const char partition_symbol)
Gets free space on the specified partition.
Definition: micros_filesystem.c:90
bool micros_filesystem_file_exists(const char *path)
Checks if file with the specified path exists.
Definition: micros_filesystem.c:78
uint8_t seconds
Seconds part.
Definition: micros_filesystem.h:27
micros_filesystem_time access_time
Access time (updated during read operation)
Definition: micros_filesystem.h:49
bool micros_filesystem_get_file_info(const char *path, micros_filesystem_file_info *file_info)
Gets information about the file with path specified in parameter.
Definition: micros_filesystem.c:3
micros_filesystem_time modify_time
Moidify time (updated during save operation)
Definition: micros_filesystem.h:46
uint8_t minutes
Minutes part.
Definition: micros_filesystem.h:24
bool micros_filesystem_get_directory_info(const char *path, micros_filesystem_directory_info *directory_info)
Gets information about the directory with path specified in parameter.
Definition: micros_filesystem.c:8
uint8_t day
Day part.
Definition: micros_filesystem.h:18
bool micros_filesystem_delete_directory(const char *path)
Deletes directory.
Definition: micros_filesystem.c:53
bool micros_filesystem_read_file(const char *path, uint8_t *buffer, const uint32_t start_index, const uint32_t length)
Reads content from the file.
Definition: micros_filesystem.c:13
uint32_t micros_filesystem_get_entries_count_in_directory(const char *path)
Gets entries count in the directory.
Definition: micros_filesystem.c:18
micros_filesystem_time create_time
Create time.
Definition: micros_filesystem.h:62
bool micros_filesystem_is_directory(const char *path)
Check if the specified entry is a directory.
Definition: micros_filesystem.c:33
bool micros_filesystem_directory_exists(const char *path)
Checks if directory with the specified path exists.
Definition: micros_filesystem.c:84
bool micros_filesystem_save_to_file(const char *path, const char *buffer, const int size)
Saves content stored in the buffer to the specified file.
Definition: micros_filesystem.c:68
uint8_t hour
Hour part.
Definition: micros_filesystem.h:21
bool micros_filesystem_get_entries_in_directory(const char *path, char **entries)
Gets pathes of the entries in the directory.
Definition: micros_filesystem.c:23
Structure representing information about the specified directory.
Definition: micros_filesystem.h:53
bool micros_filesystem_delete_file(const char *path)
Deletes file.
Definition: micros_filesystem.c:48
micros_filesystem_time create_time
Create time.
Definition: micros_filesystem.h:43
uint8_t month
Month part.
Definition: micros_filesystem.h:15
bool micros_filesystem_rename_file(const char *path, const char *new_name)
Renames file.
Definition: micros_filesystem.c:58
bool micros_filesystem_append_to_file(const char *path, const char *buffer, const int size)
Appends content stored in the buffer to the end of the specified file.
Definition: micros_filesystem.c:73
char buffer[500]
Definition: physical_memory_manager.c:5
bool micros_filesystem_is_file(const char *path)
Check if the specified entry is a file.
Definition: micros_filesystem.c:28
uint32_t size
File size.
Definition: micros_filesystem.h:40
Structure representing create/modify/access time of file or directory.
Definition: micros_filesystem.h:9
uint16_t year
Year part.
Definition: micros_filesystem.h:12
int micros_filesystem_get_total_space(const char partition_symbol)
Gets total space on the specified partition.
Definition: micros_filesystem.c:95
Structure representing information about the specified file.
Definition: micros_filesystem.h:31
size_t uint32_t
Unsigned integral type.
Definition: string.h:8
bool micros_filesystem_create_file(const char *path)
Creates file.
Definition: micros_filesystem.c:38
bool micros_filesystem_rename_directory(const char *path, const char *new_name)
Renames directory.
Definition: micros_filesystem.c:63