Skip to content

Commit

Permalink
revert changes to mv, just keep overwrite option
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Dec 12, 2023
1 parent 85b8d8a commit 758aeba
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions vlib/os/os.v
Original file line number Diff line number Diff line change
Expand Up @@ -138,24 +138,10 @@ pub fn mv_by_cp(source string, target string, opts MvParams) ! {

// mv moves files or folders from `src` to `dst`.
pub fn mv(source string, target string, opts MvParams) ! {
mut dst := target
if !opts.overwrite && exists(target) {
return error('Destination path already exist')
}
if exists(target) {
if source != target {
if !is_dir(target) {
rm(target)!
} else if is_dir(source) {
if is_dir_empty(source) {
rmdir_all(target)!
} else {
dst = join_path_single(target, file_name(source))
}
}
}
}
rename(source, dst) or { mv_by_cp(source, target, opts)! }
rename(source, target) or { mv_by_cp(source, target, opts)! }
}

// read_lines reads the file in `path` into an array of lines.
Expand Down

0 comments on commit 758aeba

Please sign in to comment.