Rename copy_file/2 to file_copy/2
This commit is contained in:
@@ -262,8 +262,8 @@ enum SystemClauseType {
|
|||||||
DeleteFile,
|
DeleteFile,
|
||||||
#[strum_discriminants(strum(props(Arity = "2", Name = "$rename_file")))]
|
#[strum_discriminants(strum(props(Arity = "2", Name = "$rename_file")))]
|
||||||
RenameFile,
|
RenameFile,
|
||||||
#[strum_discriminants(strum(props(Arity = "2", Name = "$copy_file")))]
|
#[strum_discriminants(strum(props(Arity = "2", Name = "$file_copy")))]
|
||||||
CopyFile,
|
FileCopy,
|
||||||
#[strum_discriminants(strum(props(Arity = "2", Name = "$working_directory")))]
|
#[strum_discriminants(strum(props(Arity = "2", Name = "$working_directory")))]
|
||||||
WorkingDirectory,
|
WorkingDirectory,
|
||||||
#[strum_discriminants(strum(props(Arity = "1", Name = "$delete_directory")))]
|
#[strum_discriminants(strum(props(Arity = "1", Name = "$delete_directory")))]
|
||||||
@@ -1613,7 +1613,7 @@ fn generate_instruction_preface() -> TokenStream {
|
|||||||
&Instruction::CallMakeDirectoryPath(_) |
|
&Instruction::CallMakeDirectoryPath(_) |
|
||||||
&Instruction::CallDeleteFile(_) |
|
&Instruction::CallDeleteFile(_) |
|
||||||
&Instruction::CallRenameFile(_) |
|
&Instruction::CallRenameFile(_) |
|
||||||
&Instruction::CallCopyFile(_) |
|
&Instruction::CallFileCopy(_) |
|
||||||
&Instruction::CallWorkingDirectory(_) |
|
&Instruction::CallWorkingDirectory(_) |
|
||||||
&Instruction::CallDeleteDirectory(_) |
|
&Instruction::CallDeleteDirectory(_) |
|
||||||
&Instruction::CallPathCanonical(_) |
|
&Instruction::CallPathCanonical(_) |
|
||||||
@@ -1828,7 +1828,7 @@ fn generate_instruction_preface() -> TokenStream {
|
|||||||
&Instruction::ExecuteMakeDirectoryPath(_) |
|
&Instruction::ExecuteMakeDirectoryPath(_) |
|
||||||
&Instruction::ExecuteDeleteFile(_) |
|
&Instruction::ExecuteDeleteFile(_) |
|
||||||
&Instruction::ExecuteRenameFile(_) |
|
&Instruction::ExecuteRenameFile(_) |
|
||||||
&Instruction::ExecuteCopyFile(_) |
|
&Instruction::ExecuteFileCopy(_) |
|
||||||
&Instruction::ExecuteWorkingDirectory(_) |
|
&Instruction::ExecuteWorkingDirectory(_) |
|
||||||
&Instruction::ExecuteDeleteDirectory(_) |
|
&Instruction::ExecuteDeleteDirectory(_) |
|
||||||
&Instruction::ExecutePathCanonical(_) |
|
&Instruction::ExecutePathCanonical(_) |
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ In this library, directories and files are represented as
|
|||||||
directory_exists/1,
|
directory_exists/1,
|
||||||
delete_file/1,
|
delete_file/1,
|
||||||
rename_file/2,
|
rename_file/2,
|
||||||
copy_file/2,
|
file_copy/2,
|
||||||
delete_directory/1,
|
delete_directory/1,
|
||||||
make_directory/1,
|
make_directory/1,
|
||||||
make_directory_path/1,
|
make_directory_path/1,
|
||||||
@@ -151,10 +151,13 @@ rename_file(File, Renamed) :-
|
|||||||
must_be(chars, Renamed),
|
must_be(chars, Renamed),
|
||||||
'$rename_file'(File, Renamed).
|
'$rename_file'(File, Renamed).
|
||||||
|
|
||||||
copy_file(File, Copied) :-
|
%% file_copy(+File, +Copied).
|
||||||
file_must_exist(File, copy_file/2),
|
%
|
||||||
|
% Succeeds if File is copied to Copied
|
||||||
|
file_copy(File, Copied) :-
|
||||||
|
file_must_exist(File, file_copy/2),
|
||||||
must_be(chars, Copied),
|
must_be(chars, Copied),
|
||||||
'$copy_file'(File, Copied).
|
'$file_copy'(File, Copied).
|
||||||
|
|
||||||
%% delete_directory(+Directory).
|
%% delete_directory(+Directory).
|
||||||
%
|
%
|
||||||
|
|||||||
@@ -3533,12 +3533,12 @@ impl Machine {
|
|||||||
self.rename_file();
|
self.rename_file();
|
||||||
step_or_fail!(self, self.machine_st.p = self.machine_st.cp);
|
step_or_fail!(self, self.machine_st.p = self.machine_st.cp);
|
||||||
}
|
}
|
||||||
&Instruction::CallCopyFile(_) => {
|
&Instruction::CallFileCopy(_) => {
|
||||||
self.copy_file();
|
self.file_copy();
|
||||||
step_or_fail!(self, self.machine_st.p += 1);
|
step_or_fail!(self, self.machine_st.p += 1);
|
||||||
}
|
}
|
||||||
&Instruction::ExecuteCopyFile(_) => {
|
&Instruction::ExecuteFileCopy(_) => {
|
||||||
self.copy_file();
|
self.file_copy();
|
||||||
step_or_fail!(self, self.machine_st.p = self.machine_st.cp);
|
step_or_fail!(self, self.machine_st.p = self.machine_st.cp);
|
||||||
}
|
}
|
||||||
&Instruction::CallWorkingDirectory(_) => {
|
&Instruction::CallWorkingDirectory(_) => {
|
||||||
|
|||||||
@@ -1654,7 +1654,7 @@ impl Machine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn copy_file(&mut self) {
|
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(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 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() {
|
if fs::copy(file.as_str(), copied.as_str()).is_ok() {
|
||||||
|
|||||||
Reference in New Issue
Block a user