/// Heuristically accept either a trial directory, or a structure directory within one
Heuristically accept either a trial directory, or a structure directory within one
Heuristically accept either a trial directory or a structure directory within one
pub(crate) fn resolve_trial_or_structure_path(
    path: &PathAbs,
    default_subdir: impl AsRef<OsStr>, // used when a trial directory is supplied
) -> FailResult<(TrialDir, StoredStructure)>
{Ok({
    let structure_name: OsString;
    let trial_path: PathDir;
    if StoredStructure::path_is_structure(&path) {
        let parent = path.as_path().parent().ok_or_else(|| format_err!("no parent for structure dir"))?;
        structure_name = path.as_path().file_name().unwrap().into();
        trial_path = PathDir::new(parent)?;
    } else {
        trial_path = PathDir::new(path)?;
        structure_name = default_subdir.as_ref().into();
    }
    let trial = TrialDir::from_existing(trial_path.as_path())?;
    let structure = trial.read_stored_structure(structure_name)?;
    (trial, structure)
})}
pub ( crate ) fn resolve_trial_or_structure_path ( path : & PathAbs , default_subdir : impl AsRef < OsStr > , // used when a trial directory is supplied ) -> FailResult < ( TrialDir , StoredStructure ) > { Ok ( { let structure_name : OsString ; let trial_path : PathDir ; if StoredStructure :: path_is_structure ( & path ) { let parent = path . as_path ( ) . parent ( ) . ok_or_else ( | | format_err ! ( " " ) ) ? ; structure_name = path . as_path ( ) . file_name ( ) . unwrap ( ) . into ( ) ; trial_path = PathDir :: new ( parent ) ? ; } else { trial_path = PathDir :: new ( path ) ? ; structure_name = default_subdir . as_ref ( ) . into ( ) ; } let trial = TrialDir :: from_existing ( trial_path . as_path ( ) ) ? ; let structure = trial . read_stored_structure ( structure_name ) ? ; ( trial , structure ) } ) }
Heuristically accept either a trial directory, or a structure directory within one
Heuristically accept either a trial directory or a structure directory within one
path
&PathAbs
default_subdir
impl AsRef<OsStr>