pub struct NDPluginFileBase {
pub file_path: String,
pub file_name: String,
pub file_number: i32,
pub file_template: String,
pub auto_increment: bool,
pub temp_suffix: String,
pub create_dir: i32,
pub lazy_open: bool,
pub delete_driver_file: bool,
/* private fields */
}Expand description
File path/name management and capture buffering for file plugins.
Fields§
§file_path: String§file_name: String§file_number: i32§file_template: String§auto_increment: bool§temp_suffix: String§create_dir: i32§lazy_open: bool§delete_driver_file: boolImplementations§
Source§impl NDPluginFileBase
impl NDPluginFileBase
pub fn new() -> Self
Sourcepub fn create_file_name(&self) -> String
pub fn create_file_name(&self) -> String
Construct the full file path from template/path/name/number.
Mimics C epicsSnprintf(buf, ..., template, filePath, fileName, fileNumber).
Template uses printf-style: first %s → filePath, second %s → fileName,
%d (with optional width/precision like %3.3d) → fileNumber.
Sourcepub fn temp_file_path(&self) -> Option<PathBuf>
pub fn temp_file_path(&self) -> Option<PathBuf>
Get the temp file path (if temp_suffix is set).
Sourcepub fn last_written_name(&self) -> &str
pub fn last_written_name(&self) -> &str
Return the full file name that was last written.
Sourcepub fn ensure_directory(&self) -> ADResult<()>
pub fn ensure_directory(&self) -> ADResult<()>
Create directory if needed. C ADCore behavior: createDir != 0 → create directories. Positive or negative values both trigger creation (negative = depth hint in C, but in practice create_dir_all handles any depth).
Sourcepub fn process_array(
&mut self,
array: Arc<NDArray>,
writer: &mut dyn NDFileWriter,
) -> ADResult<()>
pub fn process_array( &mut self, array: Arc<NDArray>, writer: &mut dyn NDFileWriter, ) -> ADResult<()>
Process an incoming array according to the current file mode.
Sourcepub fn flush_capture(&mut self, writer: &mut dyn NDFileWriter) -> ADResult<()>
pub fn flush_capture(&mut self, writer: &mut dyn NDFileWriter) -> ADResult<()>
Flush capture buffer: open file, write all buffered arrays, close.
For writers that support multiple arrays (HDF5, NeXus), we open once, write all frames, and close once. For single-image writers (JPEG, TIFF), we open/write/close for each frame individually, auto-incrementing the filename between each.
capture_buffer means one thing throughout: the frames that have not
reached disk. A frame leaves it only once its own file is complete, so
a flush that fails part way keeps exactly the frames still owed and a
second WriteFile resumes at the first of them instead of starting
over on files that are already written under numbers file_number has
moved past.
Sourcepub fn open_stream(
&mut self,
writer: &mut dyn NDFileWriter,
array: &NDArray,
) -> ADResult<()>
pub fn open_stream( &mut self, writer: &mut dyn NDFileWriter, array: &NDArray, ) -> ADResult<()>
Open the Stream-mode file — the single owner of a stream open.
The eager open at capture start (C++ doCapture opens the file then so
a bad path is reported at capture-start rather than on the first frame,
NDPluginFile.cpp:478-479, B9) and the lazy open on the first frame both
come through here, so Stream mode’s precondition is stated once: every
frame the mode accepts is on disk when process_array returns, which is
what lets the controller publish NDFileNumCaptured per frame. A writer
that holds frames until close_file cannot keep that promise, and an
unbounded stream (NumCapture=0) never reaches a close, so the open is
refused here instead of growing in RAM behind a readback that reports
those frames as captured.
array supplies the layout the writer needs at open time. A no-op when
a file is already open.
Sourcepub fn force_close(&mut self, writer: &mut dyn NDFileWriter) -> ADResult<()>
pub fn force_close(&mut self, writer: &mut dyn NDFileWriter) -> ADResult<()>
Force a file close (used by the FilePluginClose attribute, G9). Safe to call when no file is open.
Sourcepub fn close_stream(&mut self, writer: &mut dyn NDFileWriter) -> ADResult<()>
pub fn close_stream(&mut self, writer: &mut dyn NDFileWriter) -> ADResult<()>
Close stream mode.
This transition owns is_open: from the moment the close begins, the
guard clears the marker on every exit path, so a failing close_file or
temp rename ends the open state and reports the error instead of
latching the plugin open against a file it can no longer write.