Skip to content

Commit

Permalink
Use file.copy()/unlink() to move files
Browse files Browse the repository at this point in the history
  • Loading branch information
rich-iannone committed Sep 19, 2019
1 parent 941d018 commit e52fbcc
Showing 1 changed file with 8 additions and 31 deletions.
39 changes: 8 additions & 31 deletions R/hysplit_trajectory.R
Original file line number Diff line number Diff line change
Expand Up @@ -263,38 +263,15 @@ hysplit_trajectory <- function(lat = 49.263,
dir.create(path = recep_file_path, recursive = TRUE)
}

if (any(c("mac", "unix") %in% system_type)) {

# Perform the movement of all trajectory files
# into a folder residing to the output directory
for (traj_file in trajectory_files) {

sys_cmd <-
paste0(
"(cd ", exec_dir, " && mv '", traj_file,
"' ", recep_file_path, ")"
)

system(sys_cmd)
}
}
# Move files into the output folder
file.copy(
from = file.path(exec_dir, trajectory_files),
to = recep_file_path,
copy.mode = TRUE
)

unlink(file.path(exec_dir, trajectory_files), force = TRUE)

if (system_type == "win") {

# Perform the movement of all trajectory files
# into a folder residing to the output directory
for (traj_file in trajectory_files) {

sys_cmd <-
paste0(
"(cd \"", exec_dir, "\" && move \"", traj_file, "\" \"",
recep_file_path, "\")"
)

shell(sys_cmd)
}
}

# Obtain a trajectory data frame
traj_tbl <-
trajectory_read(output_folder = recep_file_path) %>%
Expand Down

0 comments on commit e52fbcc

Please sign in to comment.