commit 27819061e96edf1ad19a4267127f16bcf9e901e5
parent e65a3d7d11c9bb6a51ba3857ccf5f682a31d46b1
Author: Drew DeVault <sir@cmpwn.com>
Date: Tue, 22 Jun 2021 14:34:55 -0400
fs::move: assert that target is a regular file
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/fs/fs.ha b/fs/fs.ha
@@ -64,8 +64,12 @@ export fn move(fs: *fs, oldpath: str, newpath: str) (void | error) = {
void => return, // Success
err: error => return err,
};
- // XXX: If an error occurs, remove the new file.
+ // TODO:
+ // - If an error occurs, remove the new file.
+ // - Move non-regular files
let st = fs::stat(fs, oldpath)?;
+ assert(st.mode & mode::REG == mode::REG,
+ "TODO: move non-regular files");
let new = fs::create(fs, newpath, st.mode)?;
defer io::close(new);
let old = fs::open(fs, oldpath)?;