Merge pull request #1658 from aarroyoc/copy_file

Add predicate file_copy/2 in library(files)
This commit is contained in:
Mark Thom
2022-12-18 21:22:25 +01:00
committed by GitHub
4 changed files with 36 additions and 2 deletions

View File

@@ -1653,6 +1653,19 @@ impl Machine {
self.machine_st.fail = true;
}
#[inline(always)]
pub(crate) fn file_copy(&mut self) {
if let Some(file) = self.machine_st.value_to_str_like(self.machine_st.registers[1]) {
if let Some(copied) = self.machine_st.value_to_str_like(self.machine_st.registers[2]) {
if fs::copy(file.as_str(), copied.as_str()).is_ok() {
return;
}
}
}
self.machine_st.fail = true;
}
#[inline(always)]
pub(crate) fn delete_directory(&mut self) {
if let Some(dir) = self.machine_st.value_to_str_like(self.machine_st.registers[1]) {