pub struct FileInfo {
pub path: PathBuf,
pub format: Option<FileSpec>,
}Expand description
Information about the path to be opened or saved.
This path might point to a file or a directory.
Fields§
§path: PathBufThe path to the selected file.
On macOS, this is already rewritten to use the extension that the user selected
with the file format property.
format: Option<FileSpec>The selected file format.
If there’re multiple different formats available
this allows understanding the kind of format that the user expects the file
to be written in. Examples could be Blender 2.4 vs Blender 2.6 vs Blender 2.8.
The path above will already contain the appropriate extension chosen in the
format property, so it is not necessary to mutate path any further.
Implementations§
Source§impl FileInfo
impl FileInfo
Sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Returns the underlying path.
Examples found in repository?
examples/open_save.rs (line 86)
77 fn command(
78 &mut self,
79 _ctx: &mut DelegateCtx,
80 _target: Target,
81 cmd: &Command,
82 data: &mut String,
83 _env: &Env,
84 ) -> Handled {
85 if let Some(file_info) = cmd.get(commands::SAVE_FILE_AS) {
86 if let Err(e) = std::fs::write(file_info.path(), &data[..]) {
87 println!("Error writing file: {e}");
88 }
89 return Handled::Yes;
90 }
91 if let Some(file_info) = cmd.get(commands::OPEN_FILE) {
92 match std::fs::read_to_string(file_info.path()) {
93 Ok(s) => {
94 let first_line = s.lines().next().unwrap_or("");
95 *data = first_line.to_owned();
96 }
97 Err(e) => {
98 println!("Error opening file: {e}");
99 }
100 }
101 return Handled::Yes;
102 }
103 Handled::No
104 }Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileInfo
impl RefUnwindSafe for FileInfo
impl Send for FileInfo
impl Sync for FileInfo
impl Unpin for FileInfo
impl UnwindSafe for FileInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
Source§fn round_into(self) -> U
fn round_into(self) -> U
Performs the conversion.