mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-25 13:18:22 +01:00
ExUtilWriteFile() to write memory segment to file
Change-Id: I4a93358e55ba5527667e017e178009251f64560e
This commit is contained in:
parent
74356eb558
commit
e9a15a37cf
@ -54,6 +54,24 @@ int ExUtilReadFile(const char* const file_name,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ExUtilWriteFile(const char* const file_name,
|
||||||
|
const uint8_t* data, size_t data_size) {
|
||||||
|
int ok;
|
||||||
|
FILE* out;
|
||||||
|
|
||||||
|
if (file_name == NULL || data == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
out = fopen(file_name, "wb");
|
||||||
|
if (out == NULL) {
|
||||||
|
fprintf(stderr, "Error! Cannot open output file '%s'\n", file_name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ok = (fwrite(data, data_size, 1, out) == 1);
|
||||||
|
fclose(out);
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(__cplusplus) || defined(c_plusplus)
|
#if defined(__cplusplus) || defined(c_plusplus)
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,6 +23,10 @@ extern "C" {
|
|||||||
int ExUtilReadFile(const char* const file_name,
|
int ExUtilReadFile(const char* const file_name,
|
||||||
const uint8_t** data, size_t* data_size);
|
const uint8_t** data, size_t* data_size);
|
||||||
|
|
||||||
|
// Write a data segment into a file named 'file_name'. Returns true if ok.
|
||||||
|
int ExUtilWriteFile(const char* const file_name,
|
||||||
|
const uint8_t* data, size_t data_size);
|
||||||
|
|
||||||
#if defined(__cplusplus) || defined(c_plusplus)
|
#if defined(__cplusplus) || defined(c_plusplus)
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user