Medical Imaging Interaction Toolkit
2024.06.00
Medical Imaging Interaction Toolkit
|
A utility class to load and save data from/to the local file system. More...
#include <mitkIOUtil.h>
Classes | |
struct | LoadInfo |
struct | ReaderOptionsFunctorBase |
struct | SaveInfo |
struct | WriterOptionsFunctorBase |
Static Public Member Functions | |
static std::string | GetProgramPath () |
static std::string | GetTempPath () |
static char | GetDirectorySeparator () |
static std::string | CreateTemporaryFile (std::ofstream &tmpStream, const std::string &templateName="XXXXXX", std::string path=std::string()) |
static std::string | CreateTemporaryFile (std::ofstream &tmpStream, std::ios_base::openmode mode, const std::string &templateName="XXXXXX", std::string path=std::string()) |
static std::string | CreateTemporaryFile (const std::string &templateName="XXXXXX", std::string path=std::string()) |
static std::string | CreateTemporaryDirectory (const std::string &templateName="XXXXXX", std::string path=std::string()) |
static DataStorage::SetOfObjects::Pointer | Load (const std::string &path, DataStorage &storage, const ReaderOptionsFunctorBase *optionsCallback=nullptr) |
Load a file into the given DataStorage. More... | |
static DataStorage::SetOfObjects::Pointer | Load (const std::string &path, const IFileReader::Options &options, DataStorage &storage) |
Load a file into the given DataStorage given user defined IFileReader::Options. More... | |
static std::vector< BaseData::Pointer > | Load (const std::string &path, const ReaderOptionsFunctorBase *optionsCallback=nullptr) |
Load a file and return the loaded data. More... | |
template<typename T > | |
static T::Pointer | Load (const std::string &path, const ReaderOptionsFunctorBase *optionsCallback=nullptr) |
static std::vector< BaseData::Pointer > | Load (const std::string &path, const IFileReader::Options &options) |
Load a file and return the loaded data. More... | |
template<typename T > | |
static T::Pointer | Load (const std::string &path, const IFileReader::Options &options) |
static DataStorage::SetOfObjects::Pointer | Load (const std::vector< std::string > &paths, DataStorage &storage, const ReaderOptionsFunctorBase *optionsCallback=nullptr) |
Loads a list of file paths into the given DataStorage. More... | |
static std::vector< BaseData::Pointer > | Load (const std::vector< std::string > &paths, const ReaderOptionsFunctorBase *optionsCallback=nullptr) |
static std::vector< BaseData::Pointer > | Load (const us::ModuleResource &usResource, std::ios_base::openmode mode=std::ios_base::in) |
Loads the contents of a us::ModuleResource and returns the corresponding mitk::BaseData. More... | |
template<typename T > | |
static T::Pointer | Load (const us::ModuleResource &usResource, std::ios_base::openmode mode=std::ios_base::in) |
static BaseData::Pointer | Load (const std::string &path, const PropertyList *properties) |
static void | Save (const mitk::BaseData *data, const std::string &path, bool setPathProperty=false) |
Save a mitk::BaseData instance. More... | |
static void | Save (const mitk::BaseData *data, const std::string &path, const IFileWriter::Options &options, bool setPathProperty=false) |
Save a mitk::BaseData instance. More... | |
static void | Save (const mitk::BaseData *data, const std::string &mimeType, const std::string &path, bool addExtension=true, bool setPathProperty=false) |
Save a mitk::BaseData instance. More... | |
static void | Save (const mitk::BaseData *data, const std::string &mimeType, const std::string &path, const mitk::IFileWriter::Options &options, bool addExtension=true, bool setPathProperty=false) |
Save a mitk::BaseData instance. More... | |
static void | Save (std::vector< SaveInfo > &saveInfos, bool setPathProperty=false) |
Use SaveInfo objects to save BaseData instances. More... | |
Static Protected Member Functions | |
static std::string | Load (std::vector< LoadInfo > &loadInfos, DataStorage::SetOfObjects *nodeResult, DataStorage *ds, const ReaderOptionsFunctorBase *optionsCallback) |
static std::string | Save (const BaseData *data, const std::string &mimeType, const std::string &path, WriterOptionsFunctorBase *optionsCallback, bool addExtension, bool setPathProperty) |
static std::string | Save (std::vector< SaveInfo > &saveInfos, WriterOptionsFunctorBase *optionsCallback, bool setPathProperty) |
A utility class to load and save data from/to the local file system.
Definition at line 49 of file mitkIOUtil.h.
|
static |
Create a temporary directory.
This method generates a uniquely named temporary directory from templateName
. The last set of six consecutive 'X' characters in templateName
is replaced with a string that makes the directory name unique.
The directory is created with read, write and executable permissions for owner only.
templateName | An optional template for the directory name. |
path | An optional path where the temporary directory should be created. Defaults to the default temp path as returned by GetTempPath(). |
mitk::Exception | if the temporary directory could not be created. |
|
static |
Creates an empty temporary file.
This method generates a unique temporary filename from templateName
and creates this file.
The file is created with read and write permissions for owner only.
This version is potentially unsafe because the created temporary file is not kept open and could be used by another process between calling this method and opening the returned
templateName | An optional template for the filename. |
path | An optional path where the temporary file should be created. Defaults to the default temp path as returned by GetTempPath(). |
mitk::Exception | if the temporary file could not be created. |
|
static |
Create and open a temporary file.
This method generates a unique temporary filename from templateName
, creates and opens the file using the output stream tmpStream
and returns the name of the newly create file.
The templateName
argument must contain six consecutive 'X' characters ("XXXXXX") and these are replaced with a string that makes the filename unique.
The file is created with read and write permissions for owner only.
tmpStream | The output stream for writing to the temporary file. |
templateName | An optional template for the filename. |
path | An optional path where the temporary file should be created. Defaults to the default temp path as returned by GetTempPath(). |
mitk::Exception | if the temporary file could not be created. |
|
static |
Create and open a temporary file.
This method generates a unique temporary filename from templateName
, creates and opens the file using the output stream tmpStream
and the specified open mode mode
and returns the name of the newly create file. The open mode is always OR'd with std::ios_base::out | std::ios_base::trunc
.
The templateName
argument must contain six consecutive 'X' characters ("XXXXXX") and these are replaced with a string that makes the filename unique.
The file is created with read and write permissions for owner only.
tmpStream | The output stream for writing to the temporary file. |
mode | The open mode for the temporary file stream. |
templateName | An optional template for the filename. |
path | An optional path where the temporary file should be created. Defaults to the default temp path as returned by GetTempPath(). |
mitk::Exception | if the temporary file could not be created. |
|
static |
Returns the Directory Seperator for the current OS.
|
static |
Get the file system path where the running executable is located.
Referenced by mitk::RenderingTestHelper::ArgcHelperClass::ArgcHelperClass().
|
static |
Get the default temporary path.
|
static |
Load a file and return the loaded data.
This method calls Load(const std::vector<std::string>&) with a one-element vector.
path | The absolute file name including the file extension. |
options | IFileReader option instance that should be used if selected reader has options. |
mitk::Exception | if path could not be loaded. |
|
inlinestatic |
Definition at line 299 of file mitkIOUtil.h.
|
static |
Load a file into the given DataStorage given user defined IFileReader::Options.
This method calls Load(const std::vector<std::string>&, DataStorage&) with a one-element vector.
path | The absolute file name including the file extension. |
options | IFileReader option instance that should be used if selected reader has options. |
storage | A DataStorage object to which the loaded data will be added. |
mitk::Exception | if path could not be loaded. |
|
static |
|
static |
Load a file and return the loaded data.
This method calls Load(const std::vector<std::string>&) with a one-element vector.
path | The absolute file name including the file extension. |
optionsCallback | Pointer to a callback instance. The callback is used by the load operation if more the suitable reader was found or the reader has options that can be set. |
mitk::Exception | if path could not be loaded. |
|
inlinestatic |
Definition at line 277 of file mitkIOUtil.h.
|
static |
Load a file into the given DataStorage.
This method calls Load(const std::vector<std::string>&, DataStorage&) with a one-element vector.
path | The absolute file name including the file extension. |
storage | A DataStorage object to which the loaded data will be added. |
optionsCallback | Pointer to a callback instance. The callback is used by the load operation if more the suitable reader was found or the reader has options that can be set. |
mitk::Exception | if path could not be loaded. |
|
static |
|
static |
Loads a list of file paths into the given DataStorage.
If an entry in paths
cannot be loaded, this method will continue to load the remaining entries into storage
and throw an exception afterwards.
paths | A list of absolute file names including the file extension. |
storage | A DataStorage object to which the loaded data will be added. |
optionsCallback | Pointer to a callback instance. The callback is used by the load operation if more the suitable reader was found or the reader has options that can be set. |
mitk::Exception | if an entry in paths could not be loaded. |
|
static |
Loads the contents of a us::ModuleResource and returns the corresponding mitk::BaseData.
usResource | a ModuleResource, representing a BaseData object |
mode | Optional parameter to set the openmode of the stream |
Should
contain either one or zero elements, since a resource stream represents one object. mitk::Exception | if no reader was found for the stream. |
|
inlinestatic |
Definition at line 337 of file mitkIOUtil.h.
|
staticprotected |
|
staticprotected |
|
static |
Save a mitk::BaseData instance.
data | The data to save. |
mimeType | The mime-type to use for writing data . |
path | The path to the image including file name and an optional file extension. |
addExtension | If true , an extension according to the given mimeType is added to path if it does not contain one. If path already contains a file name extension, it is not checked for compatibility with mimeType . |
setPathProperty |
mitk::Exception | if no writer for the combination of data and mimeType is available or the writer is not able to write the image. |
|
static |
Save a mitk::BaseData instance.
data | The data to save. |
mimeType | The mime-type to use for writing data . |
path | The path to the image including file name and an optional file extension. |
options | Configuration data for the used IFileWriter instance. |
addExtension | If true , an extension according to the given mimeType is added to path if it does not contain one. If path already contains a file name extension, it is not checked for compatibility with mimeType . |
setPathProperty |
mitk::Exception | if no writer for the combination of data and mimeType is available or the writer is not able to write the image. |
|
static |
Save a mitk::BaseData instance.
data | The data to save. |
path | The path to the image including file name and and optional file extension. If no extension is set, the default extension and mime-type for the BaseData type of data is used. |
setPathProperty |
mitk::Exception | if no writer for data is available or the writer is not able to write the image. |
|
static |
Save a mitk::BaseData instance.
data | The data to save. |
path | The path to the image including file name and an optional file extension. If no extension is set, the default extension and mime-type for the BaseData type of data is used. |
options | The IFileWriter options to use for the selected writer. |
setPathProperty |
mitk::Exception | if no writer for data is available or the writer is not able to write the image. |
|
static |
Use SaveInfo objects to save BaseData instances.
This is a low-level method for directly working with SaveInfo objects. Usually, the Save() methods taking a BaseData object as an argument are more appropriate.
saveInfos | A list of SaveInfo objects for saving contained BaseData objects. |
setPathProperty |
|
staticprotected |