mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-26 12:14:56 +00:00
Add sizep param to mg_file_read()
This commit is contained in:
1 parent
381d7cce54
commit
4528cc28ef
7 files changed
+14
-12
No files matched your search
+2
-1
@@ -33,7 +33,7 @@ int64_t mg_file_size(const char *path) {
|
||||
#endif
|
||||
}
|
||||
|
||||
char *mg_file_read(const char *path) {
|
||||
char *mg_file_read(const char *path, size_t *sizep) {
|
||||
FILE *fp;
|
||||
char *data = NULL;
|
||||
size_t size = (size_t) mg_file_size(path);
|
||||
@@ -45,6 +45,7 @@ char *mg_file_read(const char *path) {
|
||||
data = NULL;
|
||||
} else {
|
||||
data[size] = '\0';
|
||||
if (sizep != NULL) *sizep = size;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
#include "arch.h"
|
||||
#include "str.h"
|
||||
|
||||
char *mg_file_read(const char *path);
|
||||
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, ...);
|
||||
|
||||
Reference in new issue
Block a user