-
Notifications
You must be signed in to change notification settings - Fork 923
Allow moving file handles #1124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
b57e9ba
f9bdc40
4eed713
056ba42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -537,3 +537,61 @@ code = ''' | |
} | ||
lfs_unmount(&lfs) => 0; | ||
''' | ||
|
||
[cases.test_files_ishandleopen] | ||
code = ''' | ||
lfs_t lfs; | ||
lfs_format(&lfs, cfg) => 0; | ||
lfs_mount(&lfs, cfg) => 0; | ||
lfs_file_t file; | ||
|
||
lfs_file_ishandleopen(&lfs, &file) => LFS_ERR_BADF; | ||
|
||
lfs_file_open(&lfs, &file, "hello", LFS_O_CREAT | LFS_O_WRONLY) => 0; | ||
|
||
lfs_file_ishandleopen(&lfs, &file) => 0; | ||
|
||
lfs_file_close(&lfs, &file) => 0; | ||
|
||
lfs_file_ishandleopen(&lfs, &file) => LFS_ERR_BADF; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hadn't thought about the return value of Humorously, LFS_ERR_BADF is removed in v3-alpha, but we can bring it back for this purpose. LFS_ERR_BADF also makes sense for a theoretical There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That is hilarious! I was also debating LFS_ERR_INVAL, but LFS_ERR_BADF just felt right. |
||
|
||
lfs_unmount(&lfs) => 0; | ||
''' | ||
|
||
[cases.test_files_movehandle] | ||
defines.idx = [0, 1, 2] | ||
code = ''' | ||
lfs_t lfs; | ||
lfs_format(&lfs, cfg) => 0; | ||
lfs_mount(&lfs, cfg) => 0; | ||
lfs_file_t file[3]; | ||
lfs_file_open(&lfs, &file[0], "a", LFS_O_CREAT | LFS_O_WRONLY) => 0; | ||
lfs_file_open(&lfs, &file[1], "b", LFS_O_CREAT | LFS_O_WRONLY) => 0; | ||
lfs_file_open(&lfs, &file[2], "c", LFS_O_CREAT | LFS_O_WRONLY) => 0; | ||
|
||
lfs_file_t file_new; | ||
lfs_file_movehandle(&lfs, &file[idx], &file_new) => 0; | ||
|
||
for (int i = 0; i < 3; i++) { | ||
if (i == idx) { | ||
continue; | ||
} | ||
|
||
lfs_file_ishandleopen(&lfs, &file[i]) => 0; | ||
} | ||
lfs_file_ishandleopen(&lfs, &file_new) => 0; | ||
|
||
for (int i = 0; i < 3; i++) { | ||
if (i == idx) { | ||
continue; | ||
} | ||
|
||
lfs_file_close(&lfs, &file[i]) => 0; | ||
lfs_file_ishandleopen(&lfs, &file[i]) => LFS_ERR_BADF; | ||
} | ||
|
||
lfs_file_close(&lfs, &file_new) => 0; | ||
lfs_file_ishandleopen(&lfs, &file_new) => LFS_ERR_BADF; | ||
|
||
lfs_unmount(&lfs) => 0; | ||
''' |
Uh oh!
There was an error while loading. Please reload this page.