mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 08:42:40 +01:00 
			
		
		
		
	Fixed non-standard behaviour of rdwr streams
Originally had two seperate positions for reading/writing, but this is inconsistent with the the posix standard, which has a single position for reading and writing. Also added proper handling of when the file is dirty, just added an internal flag for this state. Also moved the entry out of the file struct, and rearranged some members to clean things up.
This commit is contained in:
		| @@ -14,10 +14,14 @@ TEST | ||||
| echo "--- Simple file test ---" | ||||
| tests/test.py << TEST | ||||
|     lfs_mount(&lfs, &cfg) => 0; | ||||
|     lfs_file_open(&lfs, &file[0], "hello", LFS_O_RDWR | LFS_O_CREAT | LFS_O_APPEND) => 0; | ||||
|     lfs_file_open(&lfs, &file[0], "hello", LFS_O_WRONLY | LFS_O_CREAT) => 0; | ||||
|     size = strlen("Hello World!\n"); | ||||
|     memcpy(wbuffer, "Hello World!\n", size); | ||||
|     lfs_file_write(&lfs, &file[0], wbuffer, size) => size; | ||||
|     lfs_file_close(&lfs, &file[0]) => 0; | ||||
|  | ||||
|     lfs_file_open(&lfs, &file[0], "hello", LFS_O_RDONLY) => 0; | ||||
|     size = strlen("Hello World!\n"); | ||||
|     lfs_file_read(&lfs, &file[0], rbuffer, size) => size; | ||||
|     memcmp(rbuffer, wbuffer, size) => 0; | ||||
|     lfs_file_close(&lfs, &file[0]) => 0; | ||||
|   | ||||
| @@ -211,7 +211,7 @@ tests/test.py << TEST | ||||
|     lfs_file_seek(&lfs, &file[0], pos, LFS_SEEK_SET) => pos; | ||||
|     lfs_file_write(&lfs, &file[0], buffer, size) => size; | ||||
|  | ||||
|     lfs_file_seek(&lfs, &file[0], pos, LFS_SEEK_SET) => pos; | ||||
|     lfs_file_seek(&lfs, &file[0], pos, LFS_SEEK_SET) => pos+size; | ||||
|     lfs_file_read(&lfs, &file[0], buffer, size) => size; | ||||
|     memcmp(buffer, "doggodogdog", size) => 0; | ||||
|  | ||||
| @@ -254,7 +254,7 @@ tests/test.py << TEST | ||||
|     lfs_file_seek(&lfs, &file[0], pos, LFS_SEEK_SET) => pos; | ||||
|     lfs_file_write(&lfs, &file[0], buffer, size) => size; | ||||
|  | ||||
|     lfs_file_seek(&lfs, &file[0], pos, LFS_SEEK_SET) => pos; | ||||
|     lfs_file_seek(&lfs, &file[0], pos, LFS_SEEK_SET) => pos+size; | ||||
|     lfs_file_read(&lfs, &file[0], buffer, size) => size; | ||||
|     memcmp(buffer, "doggodogdog", size) => 0; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user