@@ -1986,10 +1986,7 @@ impl Machine {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn directory_files(&mut self) -> CallResult {
|
pub(crate) fn directory_files(&mut self) -> CallResult {
|
||||||
if let Some(dir) = self
|
if let Some(dir) = self.machine_st.value_to_str_like(self.deref_register(1)) {
|
||||||
.machine_st
|
|
||||||
.value_to_str_like(self.deref_register(1))
|
|
||||||
{
|
|
||||||
let str = dir.as_str();
|
let str = dir.as_str();
|
||||||
let path = std::path::Path::new(&*str);
|
let path = std::path::Path::new(&*str);
|
||||||
let mut files = Vec::new();
|
let mut files = Vec::new();
|
||||||
@@ -2039,10 +2036,7 @@ impl Machine {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn file_size(&mut self) {
|
pub(crate) fn file_size(&mut self) {
|
||||||
if let Some(file) = self
|
if let Some(file) = self.machine_st.value_to_str_like(self.deref_register(1)) {
|
||||||
.machine_st
|
|
||||||
.value_to_str_like(self.deref_register(1))
|
|
||||||
{
|
|
||||||
let len = Number::arena_from(
|
let len = Number::arena_from(
|
||||||
fs::metadata(&*file.as_str()).unwrap().len(),
|
fs::metadata(&*file.as_str()).unwrap().len(),
|
||||||
&mut self.machine_st.arena,
|
&mut self.machine_st.arena,
|
||||||
@@ -2064,10 +2058,7 @@ impl Machine {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn file_exists(&mut self) {
|
pub(crate) fn file_exists(&mut self) {
|
||||||
if let Some(file) = self
|
if let Some(file) = self.machine_st.value_to_str_like(self.deref_register(1)) {
|
||||||
.machine_st
|
|
||||||
.value_to_str_like(self.deref_register(1))
|
|
||||||
{
|
|
||||||
let file_str = file.as_str();
|
let file_str = file.as_str();
|
||||||
|
|
||||||
if !std::path::Path::new(&*file_str).exists()
|
if !std::path::Path::new(&*file_str).exists()
|
||||||
@@ -2082,10 +2073,7 @@ impl Machine {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn directory_exists(&mut self) {
|
pub(crate) fn directory_exists(&mut self) {
|
||||||
if let Some(dir) = self
|
if let Some(dir) = self.machine_st.value_to_str_like(self.deref_register(1)) {
|
||||||
.machine_st
|
|
||||||
.value_to_str_like(self.deref_register(1))
|
|
||||||
{
|
|
||||||
let dir_str = dir.as_str();
|
let dir_str = dir.as_str();
|
||||||
|
|
||||||
if !std::path::Path::new(&*dir_str).exists()
|
if !std::path::Path::new(&*dir_str).exists()
|
||||||
@@ -2100,10 +2088,7 @@ impl Machine {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn file_time(&mut self) {
|
pub(crate) fn file_time(&mut self) {
|
||||||
if let Some(file) = self
|
if let Some(file) = self.machine_st.value_to_str_like(self.deref_register(1)) {
|
||||||
.machine_st
|
|
||||||
.value_to_str_like(self.deref_register(1))
|
|
||||||
{
|
|
||||||
let which = cell_as_atom!(self.deref_register(2));
|
let which = cell_as_atom!(self.deref_register(2));
|
||||||
|
|
||||||
if let Ok(md) = fs::metadata(&*file.as_str()) {
|
if let Ok(md) = fs::metadata(&*file.as_str()) {
|
||||||
@@ -2139,10 +2124,7 @@ impl Machine {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn make_directory(&mut self) {
|
pub(crate) fn make_directory(&mut self) {
|
||||||
if let Some(dir) = self
|
if let Some(dir) = self.machine_st.value_to_str_like(self.deref_register(1)) {
|
||||||
.machine_st
|
|
||||||
.value_to_str_like(self.deref_register(1))
|
|
||||||
{
|
|
||||||
match fs::create_dir(&*dir.as_str()) {
|
match fs::create_dir(&*dir.as_str()) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -2156,10 +2138,7 @@ impl Machine {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn make_directory_path(&mut self) {
|
pub(crate) fn make_directory_path(&mut self) {
|
||||||
if let Some(dir) = self
|
if let Some(dir) = self.machine_st.value_to_str_like(self.deref_register(1)) {
|
||||||
.machine_st
|
|
||||||
.value_to_str_like(self.deref_register(1))
|
|
||||||
{
|
|
||||||
match fs::create_dir_all(&*dir.as_str()) {
|
match fs::create_dir_all(&*dir.as_str()) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -2173,10 +2152,7 @@ impl Machine {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn delete_file(&mut self) {
|
pub(crate) fn delete_file(&mut self) {
|
||||||
if let Some(file) = self
|
if let Some(file) = self.machine_st.value_to_str_like(self.deref_register(1)) {
|
||||||
.machine_st
|
|
||||||
.value_to_str_like(self.deref_register(1))
|
|
||||||
{
|
|
||||||
match fs::remove_file(&*file.as_str()) {
|
match fs::remove_file(&*file.as_str()) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -2188,14 +2164,8 @@ impl Machine {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn rename_file(&mut self) {
|
pub(crate) fn rename_file(&mut self) {
|
||||||
if let Some(file) = self
|
if let Some(file) = self.machine_st.value_to_str_like(self.deref_register(1)) {
|
||||||
.machine_st
|
if let Some(renamed) = self.machine_st.value_to_str_like(self.deref_register(2)) {
|
||||||
.value_to_str_like(self.deref_register(1))
|
|
||||||
{
|
|
||||||
if let Some(renamed) = self
|
|
||||||
.machine_st
|
|
||||||
.value_to_str_like(self.deref_register(2))
|
|
||||||
{
|
|
||||||
if fs::rename(&*file.as_str(), &*renamed.as_str()).is_ok() {
|
if fs::rename(&*file.as_str(), &*renamed.as_str()).is_ok() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2207,14 +2177,8 @@ impl Machine {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn file_copy(&mut self) {
|
pub(crate) fn file_copy(&mut self) {
|
||||||
if let Some(file) = self
|
if let Some(file) = self.machine_st.value_to_str_like(self.deref_register(1)) {
|
||||||
.machine_st
|
if let Some(copied) = self.machine_st.value_to_str_like(self.deref_register(2)) {
|
||||||
.value_to_str_like(self.deref_register(1))
|
|
||||||
{
|
|
||||||
if let Some(copied) = self
|
|
||||||
.machine_st
|
|
||||||
.value_to_str_like(self.deref_register(2))
|
|
||||||
{
|
|
||||||
if fs::copy(&*file.as_str(), &*copied.as_str()).is_ok() {
|
if fs::copy(&*file.as_str(), &*copied.as_str()).is_ok() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2226,10 +2190,7 @@ impl Machine {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn delete_directory(&mut self) {
|
pub(crate) fn delete_directory(&mut self) {
|
||||||
if let Some(dir) = self
|
if let Some(dir) = self.machine_st.value_to_str_like(self.deref_register(1)) {
|
||||||
.machine_st
|
|
||||||
.value_to_str_like(self.deref_register(1))
|
|
||||||
{
|
|
||||||
match fs::remove_dir(&*dir.as_str()) {
|
match fs::remove_dir(&*dir.as_str()) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -2283,10 +2244,7 @@ impl Machine {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn path_canonical(&mut self) -> CallResult {
|
pub(crate) fn path_canonical(&mut self) -> CallResult {
|
||||||
if let Some(path) = self
|
if let Some(path) = self.machine_st.value_to_str_like(self.deref_register(1)) {
|
||||||
.machine_st
|
|
||||||
.value_to_str_like(self.deref_register(1))
|
|
||||||
{
|
|
||||||
if let Ok(canonical) = fs::canonicalize(&*path.as_str()) {
|
if let Ok(canonical) = fs::canonicalize(&*path.as_str()) {
|
||||||
let cs = match canonical.to_str() {
|
let cs = match canonical.to_str() {
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
|
|||||||
@@ -119,7 +119,10 @@ fn issue_make_directory() {
|
|||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(miri, ignore = "it takes too long to run")]
|
#[cfg_attr(miri, ignore = "it takes too long to run")]
|
||||||
fn issue_make_directory_path() {
|
fn issue_make_directory_path() {
|
||||||
load_module_test("tests-pl/issue_make_directory_path.pl", "directory_path_made");
|
load_module_test(
|
||||||
|
"tests-pl/issue_make_directory_path.pl",
|
||||||
|
"directory_path_made",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[serial]
|
#[serial]
|
||||||
|
|||||||
Reference in New Issue
Block a user