MCPcopy Create free account
hub / github.com/beefytech/Beef / BfpFile_Copy

Function BfpFile_Copy

BeefySysLib/platform/win/Platform.cpp:3373–3410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3371}
3372
3373BFP_EXPORT void BFP_CALLTYPE BfpFile_Copy(const char* oldName, const char* newName, BfpFileCopyKind copyKind, BfpFileResult* outResult)
3374{
3375 if (copyKind == BfpFileCopyKind_IfNewer)
3376 {
3377 BfpTimeStamp fromTime = 0;
3378 GetFileInfo(oldName, &fromTime, NULL);
3379 BfpTimeStamp toTime = 0;
3380 GetFileInfo(newName, &toTime, NULL);
3381
3382 if ((toTime != 0) && (toTime >= fromTime))
3383 {
3384 OUTRESULT(BfpFileResult_Ok);
3385 return;
3386 }
3387 }
3388
3389 UTF16String wOldPath = UTF8Decode(oldName);
3390 UTF16String wNewPath = UTF8Decode(newName);
3391 if (!::CopyFileW(wOldPath.c_str(), wNewPath.c_str(), copyKind == BfpFileCopyKind_IfNotExists))
3392 {
3393 switch (::GetLastError())
3394 {
3395 case ERROR_ALREADY_EXISTS:
3396 OUTRESULT(BfpFileResult_AlreadyExists);
3397 break;
3398 case ERROR_PATH_NOT_FOUND:
3399 OUTRESULT(BfpFileResult_NotFound);
3400 break;
3401 default:
3402 OUTRESULT(BfpFileResult_UnknownError);
3403 break;
3404 }
3405 }
3406 else
3407 {
3408 OUTRESULT(BfpFileResult_Ok);
3409 }
3410}
3411
3412BFP_EXPORT void BFP_CALLTYPE BfpFile_Rename(const char* oldName, const char* newName, BfpFileResult* outResult)
3413{

Callers 3

CopyFileMethod · 0.50
CopyFileMethod · 0.50
ExecuteMethod · 0.50

Calls 2

GetFileInfoFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected