Skip to content

Commit

Permalink
update demo fixing filename buffer size
Browse files Browse the repository at this point in the history
  • Loading branch information
ironsheep committed Nov 27, 2023
1 parent f143e7d commit 831758c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion flash_fs.spin2
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ con { PUBLIC driver constants }
WORD_IN_BODY_BLOCK = BYTES_IN_BODY_BLOCK/2
LONGS_IN_BODY_BLOCK = BYTES_IN_BODY_BLOCK/4


con { PRIVATE driver constants }

' optionally customizable
Expand Down Expand Up @@ -759,6 +758,7 @@ pub exists(p_filename) : bool


pri exists_no_lock(p_filename) : bool

' Determine if named file is present in the file system
' . (internal version - for use when caller has already grabbed lock)
'
Expand Down
8 changes: 5 additions & 3 deletions flash_fs_demo.spin2
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ PUB go() : status
ShowFiles()

Flash.unmount()
debug("Done")
repeat

PRI showError(pCaller, errorCode)
debug("EEEE ", zstr_(pCaller), " error: ", zstr_(Flash.string_for_error(errorCode)))
Expand All @@ -62,12 +64,12 @@ PRI ShowStats() | BlocksUsed, BlocksFree, Files
debug(udec(BlocksUsed, BlocksFree, Files))


PRI ShowFiles() | ID, Bytes, handle, Ptr, x, byte Filename[60], byte Buff[30]
PRI ShowFiles() | ID, ByteCount, handle, Ptr, x, byte Filename[127+1], byte Buff[30]
repeat
Flash.Directory(@ID, @Filename, @Bytes) 'get next file
Flash.Directory(@ID, @Filename, @ByteCount) 'get next file
if Filename[0] 'is there a filename?
ReadFile(@Filename, @Buff, 30) 'read file
debug(zstr(@Filename), udec(Bytes, ID), zstr(@Buff)) 'show filename, bytes, ID, and file contents
debug(zstr(@Filename), udec(ByteCount, ID), zstr(@Buff)) 'show filename, bytes, ID, and file contents
else
quit 'no more files, quit

Expand Down

0 comments on commit 831758c

Please sign in to comment.