mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-07 16:01:30 +00:00
Remove mg_file_size()
This commit is contained in:
1 parent
529faa1172
commit
328a87b02a
5 files changed
+8
-32
No files matched your search
+4
-11
@@ -13,21 +13,14 @@ int mg_stat(const char *path, mg_stat_t *st) {
|
||||
#endif
|
||||
}
|
||||
|
||||
int64_t mg_file_size(const char *path) {
|
||||
#if MG_ARCH == MG_ARCH_FREERTOS_TCP && defined(MG_ENABLE_FF)
|
||||
struct FF_STAT st;
|
||||
return ff_stat(path, &st) == 0 ? st.st_size : 0;
|
||||
#else
|
||||
mg_stat_t st;
|
||||
return mg_stat(path, &st) == 0 ? st.st_size : 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
char *mg_file_read(const char *path, size_t *sizep) {
|
||||
FILE *fp;
|
||||
char *data = NULL;
|
||||
size_t size = (size_t) mg_file_size(path);
|
||||
size_t size = 0;
|
||||
if ((fp = fopen(path, "rb")) != NULL) {
|
||||
fseek(fp, 0, SEEK_END);
|
||||
size = (size_t) ftell(fp);
|
||||
rewind(fp);
|
||||
data = (char *) calloc(1, size + 1);
|
||||
if (data != NULL) {
|
||||
if (fread(data, 1, size, fp) != size) {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#endif
|
||||
|
||||
char *mg_file_read(const char *path, size_t *size);
|
||||
int64_t mg_file_size(const char *path);
|
||||
bool mg_file_write(const char *path, const void *buf, size_t len);
|
||||
bool mg_file_printf(const char *path, const char *fmt, ...);
|
||||
void mg_random(void *buf, size_t len) WEAK;
|
||||
|
||||
Reference in new issue
Block a user