MeVisLab Toolbox Reference
mlReleaseToolsIO.h
Go to the documentation of this file.
1 // Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2 // **InsertLicense** code
3 //----------------------------------------------------------------------------------
5 
10 //----------------------------------------------------------------------------------
11 #pragma once
12 
13 // Local includes
14 #include "MLReleaseToolsSystem.h"
15 
16 // ML includes
17 #include <mlModuleIncludes.h>
18 #include <mlAPI.h>
19 
20 // Calculates transformation from one directory to another.
21 #include "mlDirectoryMatching.h"
22 
23 #include <list>
24 
25 ML_START_NAMESPACE
26 
27 // Forward of internally used classes.
28 class MLImageFormat;
29 class ProgressLogger;
30 
31 //----------------------------------------------------------------------------------
33 //----------------------------------------------------------------------------------
34 namespace ReleaseToolsIO {
35 
36  //--------------------------------
37  // File suffix and type checks.
38  //--------------------------------
46  MLRELEASE_TOOLS_EXPORT bool isDICOMTiffPair(const std::string &oneFile,
47  std::string *otherFile=nullptr,
48  std::string *dcmFile=nullptr,
49  std::string *tiffFile=nullptr);
50 
53  MLRELEASE_TOOLS_EXPORT bool hasMLImageSuffix(const std::string &filePathWithName) ML_RETURN_VALUE_SHOULD_BE_USED;
54 
59  MLRELEASE_TOOLS_EXPORT bool isFileOrSuffixInList(const std::string &fileNamePath,
60  const std::vector<std::string> sufList) ML_RETURN_VALUE_SHOULD_BE_USED;
61 
66  MLRELEASE_TOOLS_EXPORT std::string searchFileTypeInBinaryHeader(const std::string &fullFilePath) ML_RETURN_VALUE_SHOULD_BE_USED;
67 
68 
69  //--------------------------------
70  // Some simple path handling.
71  //--------------------------------
93  MLRELEASE_TOOLS_EXPORT std::string buildRelativePath(bool useRelativePaths,
94  const std::string &fileRootDirPath,
95  const std::string &fNamePath,
96  bool allowBranchedSubDirs=false,
97  bool allowMultiFrameHandles=false) ML_RETURN_VALUE_SHOULD_BE_USED;
98 
104  MLRELEASE_TOOLS_EXPORT std::string removeRedundantPathComponents(const std::string &pathAndFileNameStr) ML_RETURN_VALUE_SHOULD_BE_USED;
105 
107  MLRELEASE_TOOLS_EXPORT void removeRedundantPathComponents(const std::string &pathToSimplify, std::string &simplifiedPath);
108 
112 
128  MLRELEASE_TOOLS_EXPORT std::string buildAbsolutePath(bool allowMakeAbsolute,
129  const std::string &fileRootDirPath,
130  const std::string &relativeFileNameStr,
131  bool simplifyPaths=false,
132  bool allowMultiFrameHandles=false) ML_RETURN_VALUE_SHOULD_BE_USED;
133 
135  MLRELEASE_TOOLS_EXPORT void buildAbsolutePath(bool allowMakeAbsolute,
136  const std::string fileRootDirPath,
137  const std::string &relativeFileNameStrIn,
138  bool simplifyPaths,
139  bool allowMultiFrameHandles,
140  std::string &relPathFileName);
141 
146  MLRELEASE_TOOLS_EXPORT std::string appendSingleSlash(const std::string &srcStr) ML_RETURN_VALUE_SHOULD_BE_USED;
147 
198  MLRELEASE_TOOLS_EXPORT std::vector<std::string> splitFilePath(const std::string &pathLikeString) ML_RETURN_VALUE_SHOULD_BE_USED;
199 
201  MLRELEASE_TOOLS_EXPORT void splitFilePath(const std::string &pathLikeString, std::vector<std::string> &retPath);
202 
212  MLRELEASE_TOOLS_EXPORT void splitPathAndName(std::string fullPathAndName,
213  std::string &fPath,
214  std::string &fName);
215 
220  MLRELEASE_TOOLS_EXPORT std::string substituteNonPathLikeChars(std::string strToCorrect) ML_RETURN_VALUE_SHOULD_BE_USED;
221 
222 
223  //--------------------------------
224  // Save/load tool functions.
225  //--------------------------------
234  MLRELEASE_TOOLS_EXPORT MLErrorCode loadStringFile(const std::string &strFileName,
235  std::string &readString) ML_RETURN_VALUE_SHOULD_BE_USED;
236 
260  MLint frameOffset,
261  SubImage &outSubImg,
262  size_t dimIdx,
263  bool isInterleaved,
264  MLint timeUnrollSteps) ML_RETURN_VALUE_SHOULD_BE_USED;
265 
299  const std::string &sourceDir,
300  const std::vector<std::string> *suppressedFilesAndSuffixes,
301  bool recursively,
302  std::vector<std::string> &resultFileVector,
303  std::vector<std::string> *resultDirVector=nullptr,
304  bool returnRelativePaths=false,
305  bool alsoSuppressDirectories=false,
306  bool warnNoSourceSourceDir=false,
307  float progressMinimum=0.0,
308  float progressMaximum=1.0,
309  std::vector<std::string> *checkForFileExtensions = nullptr,
310  bool *checkForFileExtensionsFound = nullptr);
311 
318  MLRELEASE_TOOLS_EXPORT MLErrorCode deleteListOfFiles(std::list<std::string> *fileNameList,
319  ProgressLogger *progressLogger = nullptr);
320 
321 };
322 
323 ML_END_NAMESPACE
Project global and OS specific declarations.
#define MLRELEASE_TOOLS_EXPORT
DLL export macro definition.
Configurable logger and progress handler class which can be used as base class for logging,...
This class manages/represents a rectangular 6d image region which is organized linearly in memory.
Definition: mlSubImage.h:75
MLint32 MLErrorCode
Type of an ML Error code.
Definition: mlTypeDefs.h:818
Tool function(s) to determine translation information from one directory to another.
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition: mlTypeDefs.h:578
MLRELEASE_TOOLS_EXPORT void buildAbsolutePath(bool allowMakeAbsolute, const std::string fileRootDirPath, const std::string &relativeFileNameStrIn, bool simplifyPaths, bool allowMultiFrameHandles, std::string &relPathFileName)
Same as std::string buildAbsolutePath(...) but returning result in relPathFileName.
MLRELEASE_TOOLS_EXPORT void splitFilePath(const std::string &pathLikeString, std::vector< std::string > &retPath)
Same as splitFilePath(const std::string &pathLikeString), only returning the result in retVal;.
MLRELEASE_TOOLS_EXPORT std::string buildRelativePath(bool useRelativePaths, const std::string &fileRootDirPath, const std::string &fNamePath, bool allowBranchedSubDirs=false, bool allowMultiFrameHandles=false) ML_RETURN_VALUE_SHOULD_BE_USED
Helper function to make a path relative if it matches a passed parent path.
MLRELEASE_TOOLS_EXPORT MLErrorCode loadStringFile(const std::string &strFileName, std::string &readString) ML_RETURN_VALUE_SHOULD_BE_USED
Load a binary file into readString and return ML_RESULT_OK on success, ML_FILE_IO_ERROR on other file...
MLRELEASE_TOOLS_EXPORT bool isDICOMTiffPair(const std::string &oneFile, std::string *otherFile=nullptr, std::string *dcmFile=nullptr, std::string *tiffFile=nullptr)
Returns true if oneFile is one of two files of a DICOM/Tiff pair, otherwise false.
MLRELEASE_TOOLS_EXPORT std::string searchFileTypeInBinaryHeader(const std::string &fullFilePath) ML_RETURN_VALUE_SHOULD_BE_USED
If a known one is found then it returns the suffix corresponding to the format, otherwise an empty st...
MLRELEASE_TOOLS_EXPORT MLErrorCode reformatColorChannels(const std::vector< SubImage > &frameSubImgs, MLint frameOffset, SubImage &outSubImg, size_t dimIdx, bool isInterleaved, MLint timeUnrollSteps) ML_RETURN_VALUE_SHOULD_BE_USED
Helper function to copy data from frameSubImages into outSubImg into the dimension given by dimIdx.
MLRELEASE_TOOLS_EXPORT bool isFileOrSuffixInList(const std::string &fileNamePath, const std::vector< std::string > sufList) ML_RETURN_VALUE_SHOULD_BE_USED
Returns true if fileNamePath ends with a string in sufList which has a leading dot,...
MLRELEASE_TOOLS_EXPORT MLErrorCode deleteListOfFiles(std::list< std::string > *fileNameList, ProgressLogger *progressLogger=nullptr)
Tool function that deletes files for a given list of filenames.
MLRELEASE_TOOLS_EXPORT void removeRedundantPathComponents(const std::string &pathToSimplify, std::string &simplifiedPath)
Same as removeRedundantPathComponents(const std::string &pathAndFileNameStr) but returning value in s...
MLRELEASE_TOOLS_EXPORT void removeRedundantPathComponentsInPlace(std::string &pathToSimplify)
Same as removeRedundantPathComponents(const std::string &pathAndFileNameStr) but passing input into i...
MLRELEASE_TOOLS_EXPORT bool hasMLImageSuffix(const std::string &filePathWithName) ML_RETURN_VALUE_SHOULD_BE_USED
Returns true if the if filePathWithName ends with a string compatible with the .mlimage file format,...
MLRELEASE_TOOLS_EXPORT std::string appendSingleSlash(const std::string &srcStr) ML_RETURN_VALUE_SHOULD_BE_USED
Appends a single forward slash to srcStr if it still does not end with one, however,...
MLRELEASE_TOOLS_EXPORT bool scanDirectoriesForFiles(ProgressLogger *progressLogger, const std::string &sourceDir, const std::vector< std::string > *suppressedFilesAndSuffixes, bool recursively, std::vector< std::string > &resultFileVector, std::vector< std::string > *resultDirVector=nullptr, bool returnRelativePaths=false, bool alsoSuppressDirectories=false, bool warnNoSourceSourceDir=false, float progressMinimum=0.0, float progressMaximum=1.0, std::vector< std::string > *checkForFileExtensions=nullptr, bool *checkForFileExtensionsFound=nullptr)
Searches files and directories optionally recursively in sourceDir; if suppressedFilesAndSuffixes is ...
MLRELEASE_TOOLS_EXPORT void splitPathAndName(std::string fullPathAndName, std::string &fPath, std::string &fName)
Splits the full path with file fullPathAndName into two components, the base path and the fileName at...
MLRELEASE_TOOLS_EXPORT std::string substituteNonPathLikeChars(std::string strToCorrect) ML_RETURN_VALUE_SHOULD_BE_USED
Small helper function to replace some characters not suitable for paths by '-' or '.