Skip to content
Snippets Groups Projects
Commit 8caaeeee authored by rahix's avatar rahix
Browse files

feat(filesystem): Add API call to check whether FS is attached

parent 7376a31c
No related branches found
No related tags found
1 merge request!470Add epic_fs_is_attached(), os.fs_is_attached(), and make the menu automatically return from USB mode
......@@ -78,6 +78,7 @@ typedef _Bool bool;
#define API_FILE_UNLINK 0x4b
#define API_FILE_RENAME 0x4c
#define API_FILE_MKDIR 0x4d
#define API_FILE_FS_ATTACHED 0x4e
#define API_RTC_GET_SECONDS 0x50
#define API_RTC_SCHEDULE_ALARM 0x51
......@@ -2064,6 +2065,15 @@ API(API_FILE_RENAME, int epic_file_rename(const char *oldp, const char* newp));
*/
API(API_FILE_MKDIR, int epic_file_mkdir(const char *dirname));
/**
* Check whether the filesystem is currently attached and a call like
* :c:func:`epic_file_open` has a chance to succeed.
*
* :return: ``true`` if the filesystem is attached and ``false`` if the
* filesystem is not attached.
*/
API(API_FILE_FS_ATTACHED, bool epic_fs_is_attached(void));
/**
* RTC
* ===
......
......@@ -29,6 +29,17 @@ int epic_file_open(const char *filename, const char *mode)
return res;
}
bool epic_fs_is_attached(void)
{
EpicFileSystem *fs;
if (efs_lock_global(&fs) == 0) {
efs_unlock_global(fs);
return true;
} else {
return false;
}
}
int epic_file_close(int fd)
{
EpicFileSystem *fs;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment