Skip to content

Commit

Permalink
file: zpl_file_read_contents now ignores folders
Browse files Browse the repository at this point in the history
  • Loading branch information
zpl-zak committed Sep 5, 2023
1 parent f9fd923 commit 731afdc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
19.4.1 - file: zpl_file_read_contents now ignores folders.
19.4.0 - json: introduce support for ZPL_JSON_INDENT_STYLE_COMPACT output (rheatley-pervasid)
- fix SJSON value parse not detecting EOF correctly when analysing delimiter used.
example: "foo=123,bar=456" would produce 1 extra garbage field.
Expand Down
7 changes: 7 additions & 0 deletions code/source/core/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,13 @@ zpl_file_contents zpl_file_read_contents(zpl_allocator a, zpl_b32 zero_terminate

result.allocator = a;

zpl_u8 entry_type = zpl_fs_get_type(filepath);

/* ignore folders */
if (entry_type == ZPL_DIR_TYPE_FOLDER) {
return result;
}

if (zpl_file_open(&file, filepath) == ZPL_FILE_ERROR_NONE) {
zpl_isize file_size = cast(zpl_isize) zpl_file_size(&file);
if (file_size > 0) {
Expand Down

0 comments on commit 731afdc

Please sign in to comment.