MakeDirectory,
MakeDirectoryPath,
DeleteFile,
+ RenameFile,
DeleteDirectory,
WorkingDirectory,
PathCanonical,
&SystemClauseType::MakeDirectory => clause_name!("$make_directory"),
&SystemClauseType::MakeDirectoryPath => clause_name!("$make_directory_path"),
&SystemClauseType::DeleteFile => clause_name!("$delete_file"),
+ &SystemClauseType::RenameFile => clause_name!("$rename_file"),
&SystemClauseType::DeleteDirectory => clause_name!("$delete_directory"),
&SystemClauseType::WorkingDirectory => clause_name!("$working_directory"),
&SystemClauseType::PathCanonical => clause_name!("$path_canonical"),
("$make_directory", 1) => Some(SystemClauseType::MakeDirectory),
("$make_directory_path", 1) => Some(SystemClauseType::MakeDirectoryPath),
("$delete_file", 1) => Some(SystemClauseType::DeleteFile),
+ ("$rename_file", 2) => Some(SystemClauseType::RenameFile),
("$delete_directory", 1) => Some(SystemClauseType::DeleteDirectory),
("$working_directory", 2) => Some(SystemClauseType::WorkingDirectory),
("$path_canonical", 2) => Some(SystemClauseType::PathCanonical),
file_exists/1,
directory_exists/1,
delete_file/1,
+ rename_file/2,
delete_directory/1,
make_directory/1,
make_directory_path/1,
list_of_chars(File),
'$delete_file'(File).
+rename_file(File, Renamed) :-
+ file_must_exist(File, rename_file/2),
+ list_of_chars(File),
+ list_of_chars(Renamed),
+ '$rename_file'(File, Renamed).
+
delete_directory(Directory) :-
directory_must_exist(Directory, delete_directory/1),
list_of_chars(Directory),
}
}
}
+ &SystemClauseType::RenameFile => {
+ let file = self.heap_pstr_iter(self[temp_v!(1)]).to_string();
+ let renamed = self.heap_pstr_iter(self[temp_v!(2)]).to_string();
+
+ match fs::rename(file, renamed) {
+ Ok(_) => {}
+ _ => {
+ self.fail = true;
+ return Ok(());
+ }
+ }
+ }
&SystemClauseType::DeleteDirectory => {
let directory = self.heap_pstr_iter(self[temp_v!(1)]).to_string();