Dropped LFSR_TYPE_UNKNOWN

Returning the actual on-disk file type is probably more useful for users
as this gives them more information.

I was originally concerned about collisions with future internal types,
LFS_TYPE_TRAVERSAL, etc, needed for internal opened-list tracking, but
it turns out we can avoid problems by starting internal types at 0x80,
since on-disk file types are only 7-bits.

Code changes:

           code          stack
  before: 33710           2592
  after:  33694 (-0.0%)   2592 (+0.0%)
This commit is contained in:
Christopher Haster
2024-06-09 13:55:50 -05:00
parent 7fad472af5
commit 9886ebf51e
3 changed files with 4 additions and 9 deletions
+3 -3
View File
@@ -359,11 +359,11 @@ code = '''
// mount
lfsr_mount(&lfs, CFG) => 0;
// our file should appear as unknown
// our file should appear as an unknown type
struct lfs_info info;
lfsr_stat(&lfs, "b", &info) => 0;
assert(strcmp(info.name, "b") == 0);
assert(info.type == LFS_TYPE_UNKNOWN);
assert(info.type == 0x13);
assert(info.size == 0);
lfsr_dir_t dir;
@@ -382,7 +382,7 @@ code = '''
assert(info.size == strlen("hi a!"));
lfsr_dir_read(&lfs, &dir, &info) => 0;
assert(strcmp(info.name, "b") == 0);
assert(info.type == LFS_TYPE_UNKNOWN);
assert(info.type == 0x13);
assert(info.size == 0);
lfsr_dir_read(&lfs, &dir, &info) => 0;
assert(strcmp(info.name, "c") == 0);