Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed file rename caused crash in protected folder #392

Merged
merged 3 commits into from
Feb 21, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Sources/Overload/OvEditor/src/OvEditor/Core/EditorActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -952,9 +952,11 @@ void OvEditor::Core::EditorActions::PropagateFileRenameThroughSavedFilesOfType(c
{
using namespace std;

const auto tempFilePath = filesystem::path{ OvTools::Utils::SystemCalls::GetPathToAppdata() } / "rename.tmp";

{
ifstream in(entry.path().string().c_str());
ofstream out("TEMP");
ofstream out(tempFilePath.string());
string wordToReplace(">" + p_previousName + "<");
string wordToReplaceWith(">" + p_newName + "<");

Expand All @@ -970,8 +972,8 @@ void OvEditor::Core::EditorActions::PropagateFileRenameThroughSavedFilesOfType(c
out.close(); in.close();
}

std::filesystem::copy_file("TEMP", entry.path(), std::filesystem::copy_options::overwrite_existing);
std::filesystem::remove("TEMP");
std::filesystem::copy_file(tempFilePath.string(), entry.path(), std::filesystem::copy_options::overwrite_existing);
std::filesystem::remove(tempFilePath.string());
}
}
}