open pl files instead of directories (#2014)
This commit is contained in:
@@ -27,6 +27,7 @@ use std::io::{Cursor, ErrorKind, Read, Seek, SeekFrom, Write};
|
|||||||
use std::mem;
|
use std::mem;
|
||||||
use std::net::{Shutdown, TcpStream};
|
use std::net::{Shutdown, TcpStream};
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
use std::path::PathBuf;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
#[cfg(feature = "tls")]
|
#[cfg(feature = "tls")]
|
||||||
@@ -1837,7 +1838,10 @@ impl MachineState {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let file = match open_options.open(&*file_spec.as_str()) {
|
let mut path = PathBuf::from(&*file_spec.as_str());
|
||||||
|
|
||||||
|
loop {
|
||||||
|
let file = match open_options.open(&path) {
|
||||||
Ok(file) => file,
|
Ok(file) => file,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
match err.kind() {
|
match err.kind() {
|
||||||
@@ -1869,10 +1873,20 @@ impl MachineState {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(if is_input_file {
|
if path.extension().is_none() {
|
||||||
|
if let Some(metadata) = file.metadata().ok() {
|
||||||
|
if metadata.is_dir() {
|
||||||
|
path.set_extension("pl");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(if is_input_file {
|
||||||
Stream::from_file_as_input(file_spec, file, &mut self.arena)
|
Stream::from_file_as_input(file_spec, file, &mut self.arena)
|
||||||
} else {
|
} else {
|
||||||
Stream::from_file_as_output(file_spec, file, in_append_mode, &mut self.arena)
|
Stream::from_file_as_output(file_spec, file, in_append_mode, &mut self.arena)
|
||||||
})
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user