Skip to content

Commit 731afdc

Browse files
committed
file: zpl_file_read_contents now ignores folders
1 parent f9fd923 commit 731afdc

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
19.4.1 - file: zpl_file_read_contents now ignores folders.
12
19.4.0 - json: introduce support for ZPL_JSON_INDENT_STYLE_COMPACT output (rheatley-pervasid)
23
- fix SJSON value parse not detecting EOF correctly when analysing delimiter used.
34
example: "foo=123,bar=456" would produce 1 extra garbage field.

code/source/core/file.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,13 @@ zpl_file_contents zpl_file_read_contents(zpl_allocator a, zpl_b32 zero_terminate
429429

430430
result.allocator = a;
431431

432+
zpl_u8 entry_type = zpl_fs_get_type(filepath);
433+
434+
/* ignore folders */
435+
if (entry_type == ZPL_DIR_TYPE_FOLDER) {
436+
return result;
437+
}
438+
432439
if (zpl_file_open(&file, filepath) == ZPL_FILE_ERROR_NONE) {
433440
zpl_isize file_size = cast(zpl_isize) zpl_file_size(&file);
434441
if (file_size > 0) {

0 commit comments

Comments
 (0)