1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

os: make behave more like Unix "mv" command (#6300)

This commit is contained in:
Larpon
2020-09-04 13:08:47 +02:00
committed by GitHub
parent 333f355e23
commit efa49bfbb7
2 changed files with 52 additions and 2 deletions

View File

@ -58,10 +58,14 @@ pub fn file_size(path string) int {
// mv moves files or folders from `src` to `dst`.
pub fn mv(src, dst string) {
mut rdst := dst
if is_dir(rdst) {
rdst = join_path(rdst,file_name(src.trim_right(path_separator)))
}
$if windows {
C._wrename(src.to_wide(), dst.to_wide())
C._wrename(src.to_wide(), rdst.to_wide())
} $else {
C.rename(charptr(src.str), charptr(dst.str))
C.rename(charptr(src.str), charptr(rdst.str))
}
}