From 0c211cca4d7a4d836f4cb685345e44f3f2814fd1 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 21 May 2024 09:10:57 +0200 Subject: MHR-23: New CoreSystem calls and refactors. Signed-off-by: Amlal El Mahrouss --- SDK/Library/CoreSystem/Sources/File.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'SDK/Library/CoreSystem/Sources/File.c') 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 -- cgit v1.2.3