From 8c6092504aa267b3fe367833cf4a271f49cbf8e3 Mon Sep 17 00:00:00 2001 From: MineBill Date: Tue, 15 Apr 2025 12:28:45 +0300 Subject: [PATCH] Implement BfpDirectory_Rename for Posix. --- BeefySysLib/platform/posix/PosixCommon.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/BeefySysLib/platform/posix/PosixCommon.cpp b/BeefySysLib/platform/posix/PosixCommon.cpp index e108f0a9..9e54babe 100644 --- a/BeefySysLib/platform/posix/PosixCommon.cpp +++ b/BeefySysLib/platform/posix/PosixCommon.cpp @@ -1822,7 +1822,27 @@ BFP_EXPORT void BFP_CALLTYPE BfpDirectory_Create(const char* path, BfpFileResult BFP_EXPORT void BFP_CALLTYPE BfpDirectory_Rename(const char* oldName, const char* newName, BfpFileResult* outResult) { - NOT_IMPL; + if (rename(oldName, newName) != 0) + { + switch (errno) + { + case EEXIST: + OUTRESULT(BfpFileResult_AlreadyExists); + break; + case ENOTEMPTY: + OUTRESULT(BfpFileResult_NotEmpty); + break; + case EISDIR: + case ENOTDIR: + OUTRESULT(BfpFileResult_InvalidParameter); + break; + default: + OUTRESULT(BfpFileResult_UnknownError); + break; + } + } + else + OUTRESULT(BfpFileResult_Ok); } BFP_EXPORT void BFP_CALLTYPE BfpDirectory_Delete(const char* path, BfpFileResult* outResult)