MCPcopy Create free account
hub / github.com/NotYetGames/DlgSystem / RenameFile

Method RenameFile

Source/DlgSystem/Private/DlgHelper.cpp:45–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45bool FDlgHelper::RenameFile(const FString& OldPathName, const FString& NewPathName, bool bOverWrite, bool bVerbose)
46{
47 IFileManager& FileManager = IFileManager::Get();
48
49 // File we want to rename does not exist anymore
50 if (!FileManager.FileExists(*OldPathName))
51 {
52 if (bVerbose)
53 {
54 FDlgLogger::Get().Debugf(TEXT("File before rename at path = `%s` does not exist. Can't Rename."), *OldPathName);
55 }
56 return false;
57 }
58
59 // File at destination already exists, conflict :/
60 if (!bOverWrite && FileManager.FileExists(*NewPathName))
61 {
62 if (bVerbose)
63 {
64 FDlgLogger::Get().Errorf(
65 TEXT("File at destination (after rename) at path = `%s` already exists. Current text file at path = `%s` won't be moved/renamed."),
66 *NewPathName, *OldPathName
67 );
68 }
69 return false;
70 }
71
72 // Finally Move/Rename
73 if (!FileManager.Move(/*Dest=*/ *NewPathName, /*Src=*/ *OldPathName, /*bReplace=*/ bOverWrite))
74 {
75 if (bVerbose)
76 {
77 FDlgLogger::Get().Errorf(TEXT("Failure to move/rename file from `%s` to `%s`"), *OldPathName, *NewPathName);
78 }
79 return false;
80 }
81
82 if (bVerbose)
83 {
84 FDlgLogger::Get().Infof(TEXT("Text file moved/renamed from `%s` to `%s`"), *OldPathName, *NewPathName);
85 }
86 return true;
87}
88
89
90TSharedPtr<SDockTab> FDlgHelper::InvokeTab(TSharedPtr<FTabManager> TabManager, const FTabId& TabID)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected