openplanet-nl / issues

Issue tracker for Openplanet.
10 stars 0 forks source link

add `IO::MoveFolder` #472

Closed ezio416 closed 5 months ago

ezio416 commented 5 months ago

Maybe this could instead be IO::Rename that could work for files and folders, but I think MoveFolder would be more consistent with existing functions

codecat commented 5 months ago

The following code works for me:

auto path = IO::FromStorageFolder("Test");
auto newPath = IO::FromStorageFolder("Test_Moved");

IO::CreateFolder(path);
{
    IO::File f(path + "/test.txt", IO::FileMode::Write);
    f.WriteLine("Hello world");
}
IO::Move(path, newPath);

I did however change IO::Move to use MOVEFILE_WRITE_THROUGH, but that shouldn't matter too much if you're not immediately observing the directory.

ezio416 commented 5 months ago

This snippet does work, my bad. I made the issue based on the discord convo but hadn't actually tested it myself.