> TOCTOU. Also maybe out of scope?
imho not out of scope, or at least, not moreso than move(). but yeah
this patch is a little scruffy because i needed it quickly for the build
driver and didn't want to get too deep in the weeds so i just copied the
existing copying code from move() (as well as its flaws). i'll spend a
bit longer on it but i do think the function is broadly useful.
> TOCTOU. Also maybe out of scope?
having put more thought into this, i'm not sure if this is actually
buggy behavior, since the permissions are not actually used until after
the file is successfully opened, and they're just copied across to the
new file. i don't really see where the potential unexpected behavior
lies here. ~illiliti's point about the permissions being filtered
through umask is relevant though and can be fixed i think.
alternatively, if there is in fact a bug here, fixing this will require
an uncomfortably large refactor of fs:: and io::, since fstat would
probably want to be io::stat since it deals with file descriptors, but
it relies on fs::filestat, which can't be used by io since fs relies on
io already, so it might need to move to io::filestat which feels wrong.
there's a big tangled can of worms here that i don't want to get into tbqh.
~Autumn