···6162 json->file_loaded = true;
6364- char *str = u_file_read_content(file);
65 fclose(file);
66 if (str == NULL) {
67 U_LOG_E("Could not read the contents of '%s'!", tmp);
···6162 json->file_loaded = true;
6364+ char *str = u_file_read_content(file, NULL);
65 fclose(file);
66 if (str == NULL) {
67 U_LOG_E("Could not read the contents of '%s'!", tmp);
+6-3
src/xrt/auxiliary/util/u_file.c
···218}
219220char *
221-u_file_read_content(FILE *file)
222{
223 // Go to the end of the file.
224 fseek(file, 0L, SEEK_END);
···239 return NULL;
240 }
241000242 return buffer;
243}
244245char *
246-u_file_read_content_from_path(const char *path)
247{
248 FILE *file = fopen(path, "rb");
249 if (file == NULL) {
250 return NULL;
251 }
252- char *file_content = u_file_read_content(file);
253 int ret = fclose(file);
254 // We don't care about the return value since we're just reading
255 (void)ret;
···218}
219220char *
221+u_file_read_content(FILE *file, size_t *out_file_size)
222{
223 // Go to the end of the file.
224 fseek(file, 0L, SEEK_END);
···239 return NULL;
240 }
241242+ if (out_file_size)
243+ *out_file_size = file_size;
244+245 return buffer;
246}
247248char *
249+u_file_read_content_from_path(const char *path, size_t *out_file_size)
250{
251 FILE *file = fopen(path, "rb");
252 if (file == NULL) {
253 return NULL;
254 }
255+ char *file_content = u_file_read_content(file, out_file_size);
256 int ret = fclose(file);
257 // We don't care about the return value since we're just reading
258 (void)ret;
···116static bool
117ns_config_load(struct ns_builder *nsb)
118{
119- const char *file_content = u_file_read_content_from_path(nsb->config_path);
120 if (file_content == NULL) {
121 U_LOG_E("The file at \"%s\" was unable to load. Either there wasn't a file there or it was empty.",
122 nsb->config_path);
···116static bool
117ns_config_load(struct ns_builder *nsb)
118{
119+ const char *file_content = u_file_read_content_from_path(nsb->config_path, NULL);
120 if (file_content == NULL) {
121 U_LOG_E("The file at \"%s\" was unable to load. Either there wasn't a file there or it was empty.",
122 nsb->config_path);
+1-1
src/xrt/targets/common/target_builder_simulavr.c
···71static bool
72process_config(const char *config_path, struct svr_two_displays_distortion *out_dist)
73{
74- char *file_content = u_file_read_content_from_path(config_path);
75 if (file_content == NULL) {
76 U_LOG_E("The file at \"%s\" was unable to load. Either there wasn't a file there or it was empty.",
77 config_path);
···71static bool
72process_config(const char *config_path, struct svr_two_displays_distortion *out_dist)
73{
74+ char *file_content = u_file_read_content_from_path(config_path, NULL);
75 if (file_content == NULL) {
76 U_LOG_E("The file at \"%s\" was unable to load. Either there wasn't a file there or it was empty.",
77 config_path);