summaryrefslogtreecommitdiffhomepage
path: root/SDK/Library/CoreSystem/Sources/File.c
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-05-21 09:10:57 +0200
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-05-21 09:10:57 +0200
commit0c211cca4d7a4d836f4cb685345e44f3f2814fd1 (patch)
treef08901e67cdabe025d8ad40c18c62b27b32c5517 /SDK/Library/CoreSystem/Sources/File.c
parentf022a2afeb7af04ce3ef256ef617d19f07d84d9a (diff)
MHR-23: New CoreSystem calls and refactors.
Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'SDK/Library/CoreSystem/Sources/File.c')
-rw-r--r--SDK/Library/CoreSystem/Sources/File.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/SDK/Library/CoreSystem/Sources/File.c b/SDK/Library/CoreSystem/Sources/File.c
index 485500ab..7547e7f2 100644
--- a/SDK/Library/CoreSystem/Sources/File.c
+++ b/SDK/Library/CoreSystem/Sources/File.c
@@ -20,11 +20,11 @@ enum FileOp
/// @param path where to find it.
/// @param rest the restrict (rw, rwe, r+, w+, r, w)
/// @return FSRef the file.
-CS_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path,
+CS_EXTERN_C FSRef CSOpenFile(const CharacterTypeUTF8* path,
const CharacterTypeUTF8* rest)
{
CS_MUST_PASS(kSharedApplication);
- CS_MUST_PASS(path && FsIsValidPath(path) == Yes);
+ CS_MUST_PASS(path && CSIsValidPath(path) == Yes);
CS_MUST_PASS(rest);
return kSharedApplication->Invoke(kSharedApplication, kCallOpenFile, path,
@@ -32,12 +32,27 @@ CS_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path,
}
/// @brief Closes the file and flushes it to the said file.
-/// @param refFs the filesystem reference.
+/// @param refCS the filesystem reference.
/// @return
-CS_EXTERN_C VoidType FsCloseFile(FSRef refFs)
+CS_EXTERN_C VoidType CSCloseFile(FSRef refCS)
{
CS_MUST_PASS(kSharedApplication);
- kSharedApplication->Invoke(kSharedApplication, refFs, kFlushFile);
- kSharedApplication->Invoke(kSharedApplication, kCallCloseFile, refFs);
+ kSharedApplication->Invoke(kSharedApplication, refCS, kFlushFile);
+ kSharedApplication->Invoke(kSharedApplication, kCallCloseFile, refCS);
}
+
+/// @brief Check if filesystem path is valid.
+/// @param path
+/// @return
+CS_EXTERN_C BooleanType CSIsValidPath(const CharacterTypeUTF8* path)
+{
+ CS_MUST_PASS(kSharedApplication);
+ CS_MUST_PASS(path);
+
+ return kSharedApplication->Invoke(kSharedApplication, kCallFileExists, path) ||
+ kSharedApplication->Invoke(kSharedApplication, kCallDirectoryExists, path) ||
+ kSharedApplication->Invoke(kSharedApplication, kCallSymlinkExists, path) ||
+ kSharedApplication->Invoke(kSharedApplication, kCallDriveExists, path) ||
+ kSharedApplication->Invoke(kSharedApplication, kCallDeviceExists, path);
+} \ No newline at end of file