Xmipp  v3.23.11-Nereus
List of all members
FileName Class Reference

#include <xmipp_filename.h>

Inheritance diagram for FileName:
Inheritance graph
[legend]
Collaboration diagram for FileName:
Collaboration graph
[legend]

Public Member Functions

Filename constructors
 FileName ()
 
 FileName (const String &str)
 
 FileName (const char *str)
 
FileNameoperator= (const FileName &op)
 
 FileName (const FileName &fn)
 
 FileName (const char *str, int no, const String &ext="")
 
 FileName (const char *str, const String &ext)
 
 FileName (const String &str, const String &ext)
 
Composing/Decomposing the filename
String getString () const
 
bool isEmpty () const
 
void compose (const String &str, const size_t no, const String &ext="")
 
void compose (const size_t no, const String &str)
 
void compose (size_t no, const String &str, const String &ext)
 
void compose (const String &blockName, const String &str)
 
void composeBlock (const String &blockName, size_t no, const String &str, const String &ext="")
 
bool isInStack () const
 
void decompose (size_t &no, String &str) const
 
FileName getDecomposedFileName () const
 
FileName getRoot () const
 
FileName getBaseName () const
 
int getNumber () const
 
size_t getPrefixNumber (size_t pos=0) const
 
FileName getDir () const
 
String getExtension () const
 
String getFileFormat () const
 
bool hasImageExtension () const
 
bool hasStackExtension () const
 
bool hasVolumeExtension () const
 
bool hasMetadataExtension () const
 
size_t getFileSize () const
 
String getBlockName () const
 
FileName removePrefixNumber () const
 
FileName removeBlockName () const
 
FileName removeAllPrefixes () const
 
void initRandom (int length)
 
void initUniqueName (const char *templateStr="xmippTemp_XXXXXX", const String &fnDir="")
 
Filename utilities
FileName toLowercase () const
 
FileName toUppercase () const
 
bool contains (const String &str) const
 
FileName beforeFirstOf (const String &str) const
 
FileName beforeLastOf (const String &str) const
 
FileName afterFirstOf (const String &str) const
 
FileName afterLastOf (const String &str) const
 
FileName addPrefix (const String &prefix) const
 
FileName addExtension (const String &ext) const
 
FileName withoutExtension () const
 
FileName withoutRoot () const
 
FileName insertBeforeExtension (const String &str) const
 
FileName removeExtension (const String &ext) const
 
FileName removeLastExtension () const
 
FileName removeFilename () const
 
FileName removeAllExtensions () const
 
FileName removeFileFormat () const
 
bool isMetaData (bool failIfNotExists=true) const
 
bool isStar1 (bool failIfNotExists) const
 
FileName replaceSubstring (const String &subOld, const String &subNew) const
 
FileName replaceCharacter (char oldChar, char newChar) const
 
FileName replaceExtension (const String &newExt) const
 
FileName removeSubstring (const String &sub) const
 
FileName removeUntilPrefix (const String &prefix) const
 
FileName removeDirectories (int keep=0) const
 
void copyFile (const FileName &target) const
 
bool exists () const
 
void deleteFile () const
 
bool existsTrim () const
 
bool isDir () const
 
void getFiles (std::vector< FileName > &files) const
 
void waitUntilStableSize (size_t time_step=250000)
 
void createEmptyFile (size_t size, size_t block_size=102400)
 
void createEmptyFileWithGivenLength (size_t length=0) const
 
int makePath (mode_t mode=0755) const
 
void assertExists ()
 

Detailed Description

Filenames.

This class allows you a lot of usual and common manipulations with filenames. See filename conventions for a detailed explanation of the Filenames dealed here, although most of the functions work with the more general model "name.extension"

Definition at line 65 of file xmipp_filename.h.

Constructor & Destructor Documentation

◆ FileName() [1/7]

FileName::FileName ( )
inline

Empty constructor

The empty constructor is inherited from the string class, so an empty FileName is equal to "".

FileName fn_blobs;

Definition at line 80 of file xmipp_filename.h.

80  : String("")
81  {}
std::string String
Definition: xmipp_strings.h:34

◆ FileName() [2/7]

FileName::FileName ( const String str)
inline

Constructor from string

The constructor from a string allows building complex expressions based on the string class. Notice that in the following example the type casting to string is very important, if not, the operation is just a pointer movement instead of a string concatenation.

FileName fn_blobs((String) "art00001" + ".blobs");

Definition at line 94 of file xmipp_filename.h.

94  : String(str)
95  {}
std::string String
Definition: xmipp_strings.h:34

◆ FileName() [3/7]

FileName::FileName ( const char *  str)
inline

Constructor from char*

Definition at line 99 of file xmipp_filename.h.

99  : String(str)
100  {}
std::string String
Definition: xmipp_strings.h:34

◆ FileName() [4/7]

FileName::FileName ( const FileName fn)
inline

Copy constructor

Definition at line 111 of file xmipp_filename.h.

111  : String(fn)
112  {}
std::string String
Definition: xmipp_strings.h:34

◆ FileName() [5/7]

FileName::FileName ( const char *  str,
int  no,
const String ext = "" 
)
inline

Constructor from root, number and extension

The number and extension are optional.

FileName fn_proj("g1ta000001.xmp"); // fn_proj = "g1ta000001.xmp"
FileName fn_proj("g1ta",1,"xmp"); // fn_proj = "g1ta000001.xmp"
FileName fn_proj("g1ta",1); // fn_proj = "g1ta000001"

Definition at line 124 of file xmipp_filename.h.

125  {
126  compose(str, no, ext);
127  }
void compose(const String &str, const size_t no, const String &ext="")

◆ FileName() [6/7]

FileName::FileName ( const char *  str,
const String ext 
)
inline

Constructor from root and extension

None of the parameters is optional

FileName fn_proj("g1ta00001", "xmp"); // fn_proj = "g1ta00001.xmp"

Definition at line 137 of file xmipp_filename.h.

137  : String(str + ext)
138  {}
std::string String
Definition: xmipp_strings.h:34

◆ FileName() [7/7]

FileName::FileName ( const String str,
const String ext 
)
inline

Constructor from root and extension

None of the parameters is optional

FileName fn_proj("g1ta00001", "xmp"); // fn_proj = "g1ta00001.xmp"

Definition at line 148 of file xmipp_filename.h.

148  : String(str + "." + ext)
149  {}
std::string String
Definition: xmipp_strings.h:34

Member Function Documentation

◆ addExtension()

FileName FileName::addExtension ( const String ext) const

Add extension at the end.

The "." is added. If the input extension is "" then the same name is returned, with nothing added.

fn_proj = "g1ta00001";
fn_proj.add_extension("xmp"); // fn_proj == "g1ta00001.xmp"

Definition at line 332 of file xmipp_filename.cpp.

333 {
334  if (ext == "")
335  return *this;
336  else
337  {
338  FileName retval = *this;
339  retval = retval.append((String) "." + ext);
340  return retval;
341  }
342 }
std::string String
Definition: xmipp_strings.h:34

◆ addPrefix()

FileName FileName::addPrefix ( const String prefix) const

Add string at the beginning

If there is a path then the prefix is added after the path.

fn_proj = "imgs/g1ta00001";
fn_proj.add_prefix("h"); // fn_proj == "imgs/hg1ta00001"
fn_proj = "g1ta00001";
fn_proj.add_prefix("h"); // fn_proj == "hg1ta00001"

Definition at line 324 of file xmipp_filename.cpp.

325 {
326  FileName retval = *this;
327  int skip_directories = find_last_of("/") + 1;
328  return retval.insert(skip_directories, prefix);
329 }

◆ afterFirstOf()

FileName FileName::afterFirstOf ( const String str) const

Return substring after first instance of argument (as in Bsoft)

FileName fn_proj("g1ta00001.raw#d=f");
fn_proj = fn_proj.after_first_of("#"); // fn_proj = "d=f"

Definition at line 212 of file xmipp_filename.cpp.

213 {
214  size_t point = find_first_of(str);
215  return point != npos ? (FileName)substr(point + 1) : *this;
216 }

◆ afterLastOf()

FileName FileName::afterLastOf ( const String str) const

Return substring after last instance of argument (as in Bsoft)

FileName fn_proj("g1ta00001.raw#d=f");
fn_proj = fn_proj.after_last_of("#"); // fn_proj = "d=f"

Definition at line 220 of file xmipp_filename.cpp.

221 {
222  size_t point = find_last_of(str);
223  return point != npos ? (FileName)substr(point + 1) : *this;
224 }

◆ assertExists()

void FileName::assertExists ( )

This function raised an ERROR if the filename if not empty and if the corresponding file does not exist. This may be useful to have a better (killing) control on (mpi-regulated) jobs

exit_if_not_exists("control_file.txt");

This function is not ported to Python.

Definition at line 840 of file xmipp_filename.cpp.

841 {
842  if (!empty() && !exists())
843  {
844  std::cerr << "FileName::assertExists: control file" << *this
845  << " doesn't exist, exiting..." << std::endl;
846  exit(ERR_IO_NOTEXIST);
847  }
848  //TODO: Maybe change to report error???
849  //REPORT_ERROR(ERR_IO_NOTEXIST, (String)"FileName::assertExists: control file" + *this " doesn't exist, exiting...");
850 }
File or directory does not exist.
Definition: xmipp_error.h:136
bool exists() const

◆ beforeFirstOf()

FileName FileName::beforeFirstOf ( const String str) const

Return substring before first instance of argument (as in Bsoft)

FileName fn_proj("g1ta00001.raw#d=f");
fn_proj = fn_proj.before_first_of("#"); // fn_proj = "g1ta00001.raw"

Definition at line 196 of file xmipp_filename.cpp.

197 {
198  size_t point = find_first_of(str);
199  return (point != npos ? (FileName)substr(0, point) : *this);
200 }

◆ beforeLastOf()

FileName FileName::beforeLastOf ( const String str) const

Return substring before last instance of argument (as in Bsoft)

FileName fn_proj("g1ta00001.raw#d=f");
fn_proj = fn_proj.before_last_of("#"); // fn_proj = "g1ta00001.raw"

Definition at line 204 of file xmipp_filename.cpp.

205 {
206  size_t point = find_last_of(str);
207  return point != npos ? (FileName)substr(0, point) : *this;
208 }

◆ compose() [1/4]

void FileName::compose ( const String str,
const size_t  no,
const String ext = "" 
)

Compose from root, number and extension

fn_proj.compose("g1ta", 1, "xmp"); // fn_proj = "g1ta000001.xmp"

Definition at line 52 of file xmipp_filename.cpp.

53 {
54 
55  if (no == ALL_IMAGES || no == (size_t) -1)
56  REPORT_ERROR(ERR_DEBUG_TEST, "Don't compose with 0 or -1 index, now images index start at 1");
57 
58  *this = (FileName) str;
59 
60  if (no != ALL_IMAGES)
61  this->append(formatString("%06lu", no));
62 
63  if (!ext.empty())
64  *this += (String) "." + ext;
65 }
Just an error for debugging purpose.
Definition: xmipp_error.h:119
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
std::string String
Definition: xmipp_strings.h:34
#define ALL_IMAGES
String formatString(const char *format,...)

◆ compose() [2/4]

void FileName::compose ( const size_t  no,
const String str 
)

Prefix with number . Mainly for selfiles

fn_proj.compose(1,"g1ta.xmp"); // fn_proj = "000001@g1ta000001.xmp"

Definition at line 68 of file xmipp_filename.cpp.

69 {
70  if (no == ALL_IMAGES || no == (size_t) -1)
71  REPORT_ERROR(ERR_DEBUG_TEST, "Don't compose with 0 or -1 index, now images index start at 1");
72 
73  if (no != ALL_IMAGES)
74  {
75  size_t first = str.rfind(AT);
76  if (first != npos)
77  {
78  std::vector<String> prefixes;
79  int nPref = splitString(str.substr(0, first),",",prefixes, false);
80 
81  if (isalpha(prefixes[nPref-1].at(0)))
82  formatStringFast(*this, "%06lu,%s", no, str.c_str());
83  }
84  else
85  formatStringFast(*this, "%06lu@%s", no, str.c_str());
86  }
87  else
88  *this = str;
89 }
Just an error for debugging purpose.
Definition: xmipp_error.h:119
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
glob_log first
int splitString(const String &input, const String &delimiter, StringVector &results, bool includeEmpties)
#define AT
#define ALL_IMAGES
void formatStringFast(String &str, const char *format,...)

◆ compose() [3/4]

void FileName::compose ( size_t  no,
const String str,
const String ext 
)

Prefix with number and extension .

fn_proj.compose(1, "g1ta", "xmp"); // fn_proj = "000001@g1ta000001.xmp"

Definition at line 92 of file xmipp_filename.cpp.

93 {
94  if (no == ALL_IMAGES || no == (size_t) -1)
95  REPORT_ERROR(ERR_DEBUG_TEST, "Don't compose with 0 or -1 index, now images index start at 1");
96 
97  if (no != ALL_IMAGES)
98  formatStringFast(*this, "%06lu@%s.%s", no,
99  str.c_str(), ext.c_str());
100  else
101  *this = str;
102 }
Just an error for debugging purpose.
Definition: xmipp_error.h:119
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
#define ALL_IMAGES
void formatStringFast(String &str, const char *format,...)

◆ compose() [4/4]

void FileName::compose ( const String blockName,
const String str 
)

Prefix with string (blockname) .

fn_proj.compose(b00001, "g1ta.xmp"); // fn_proj = "b000001@g1ta.xmp"

Definition at line 105 of file xmipp_filename.cpp.

106 {
107  if (blockName.empty())
108  *this = str;
109  else
110  formatStringFast(*this, "%s@%s", blockName.c_str(), str.c_str());
111 }
void formatStringFast(String &str, const char *format,...)

◆ composeBlock()

void FileName::composeBlock ( const String blockName,
size_t  no,
const String str,
const String ext = "" 
)

Constructor: string, number, rootfilename and extension: mainly for numered metadata blocks..

fn_proj.composeBlock("bb",5, "g1ta","xmp"); // fn_proj = "bb000005@g1ta.xmp"
fn_proj.composeBlock("bb",5, "g1ta.xmp"); // fn_proj = "bb000005@g1ta.xmp"

Definition at line 114 of file xmipp_filename.cpp.

115 {
116  formatStringFast(*this, "%s%06lu@%s", blockName.c_str(), no, root.c_str());
117  if (ext != "")
118  *this += (String) "." + ext;
119 }
std::string String
Definition: xmipp_strings.h:34
void formatStringFast(String &str, const char *format,...)

◆ contains()

bool FileName::contains ( const String str) const

Check whether the filename contains the argument substring

FileName fn_proj("g1ta00001.raw#d=f");
if (fn_proj.contains("raw) ) // true

Definition at line 189 of file xmipp_filename.cpp.

190 {
191  return find(str) != npos;
192 }
std::vector< SelLine >::iterator find(std::vector< SelLine > &text, const std::string &img_name)
Definition: selfile.cpp:553

◆ copyFile()

void FileName::copyFile ( const FileName target) const

copy one file

Definition at line 656 of file xmipp_filename.cpp.

657 {
658  std::ifstream f1(this->c_str(), std::fstream::binary);
659  std::ofstream
660  f2(target.c_str(), std::fstream::trunc | std::fstream::binary);
661  f2 << f1.rdbuf();
662 }
int trunc(double x)
Definition: ap.cpp:7248

◆ createEmptyFile()

void FileName::createEmptyFile ( size_t  size,
size_t  block_size = 102400 
)

Write a zero filled file with the desired size.

The file is written by blocks to speed up, you can modify the block size. An exception is thrown if any error happens

Definition at line 752 of file xmipp_filename.cpp.

753 {
754  unsigned char * buffer = (unsigned char*) calloc(sizeof(unsigned char),
755  block_size);
756  if (buffer == NULL)
757  REPORT_ERROR(ERR_MEM_NOTENOUGH, "create_empty_file: No memory left");
758  FILE * fd = fopen(c_str(), "w");
759  if (fd == NULL)
760  REPORT_ERROR(ERR_IO_NOTOPEN, (String)"FileName::createEmptyFile: Cannot open file" + *this);
761  for (size_t i = 0; i < size / block_size; i++)
762  fwrite(buffer, sizeof(unsigned char), block_size, fd);
763  fwrite(buffer, sizeof(unsigned char), size % block_size, fd);
764  fclose(fd);
765  free(buffer);
766 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
HBITMAP buffer
Definition: svm-toy.cpp:37
There is not enough memory for allocation.
Definition: xmipp_error.h:166
#define i
free((char *) ob)
File cannot be open.
Definition: xmipp_error.h:137
std::string String
Definition: xmipp_strings.h:34

◆ createEmptyFileWithGivenLength()

void FileName::createEmptyFileWithGivenLength ( size_t  length = 0) const

Create empty file with a given length.

Definition at line 768 of file xmipp_filename.cpp.

769 {
770  FILE* fMap = fopen(c_str(),"wb");
771  if (!fMap)
773  if (length>0)
774  {
775  char c=0;
776  if ((fseek(fMap, length-1, SEEK_SET) == -1) || (fwrite(&c,1,1,fMap) != 1))
777  REPORT_ERROR(ERR_IO_NOWRITE,"FileName::createEmptyFileWithGivenLength: Cannot create empty file");
778  }
779  fclose(fMap);
780 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
doublereal * c
Couldn&#39;t write to file.
Definition: xmipp_error.h:140
__host__ __device__ float length(float2 v)

◆ decompose()

void FileName::decompose ( size_t &  no,
String str 
) const

Decompose filenames with . Mainly from selfiles

fn_proj.decompose(no,filename); // fn_proj = "000001@g1ta000001.xmp"
// no=1
// filename = "g1ta000001.xmp"

Definition at line 128 of file xmipp_filename.cpp.

129 {
130  char buffer[1024];
131  unsigned long int auxNo;
132  int ok = sscanf(c_str(), "%lu@%s", &auxNo, buffer);
133  no=auxNo;
134  if (ok != 2)
135  {
136  no = ALL_IMAGES;
137  str = *this;
138  return;
139  }
140  else if (no == 0)
141  REPORT_ERROR(ERR_INDEX_OUTOFBOUNDS, formatString("FileName::decompose: Incorrect index number at filename %s; It must start at %lu",c_str(),FIRST_IMAGE));
142 
143  str = buffer;
144 }
Index out of bounds.
Definition: xmipp_error.h:132
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
HBITMAP buffer
Definition: svm-toy.cpp:37
#define ALL_IMAGES
String formatString(const char *format,...)
#define FIRST_IMAGE

◆ deleteFile()

void FileName::deleteFile ( ) const

Delete the file if exists

Definition at line 670 of file xmipp_filename.cpp.

671 {
673  if (temp.exists())
674  unlink(temp.c_str());
675 }
FileName removeFileFormat() const
FileName removeAllPrefixes() const
bool exists() const

◆ exists()

bool FileName::exists ( ) const

True if the filename exists, check from current directory if is relative

FileName fn("g1ta0001");
if (fn.exists())
std::cout << "The file exists" << std::endl;

Definition at line 665 of file xmipp_filename.cpp.

666 {
668 }
FileName removeFileFormat() const
bool fileExists(const char *filename)
FileName getDecomposedFileName() const

◆ existsTrim()

bool FileName::existsTrim ( ) const

True if the file exists in the current directory Remove leading xx@ and tailing :xx

if (exists("g1ta00001"))
std::cout << "The file exists" << std::endl;

Definition at line 677 of file xmipp_filename.cpp.

678 {
679  FileName auxF(*this);
680  size_t found = find_first_of(AT);
681 
682  if (found != String::npos)
683  auxF = substr(found+1);
684 
685  found = auxF.find_first_of(NUM);
686 
687  if ( found != String::npos)
688  auxF = auxF.substr(0, found);
689  found = auxF.find_first_of(COLON);
690 
691  if (found != String::npos)
692  auxF = auxF.substr(0, found);
693  return fileExists(auxF.c_str());
694 }
#define NUM
#define AT
bool fileExists(const char *filename)
#define COLON

◆ getBaseName()

FileName FileName::getBaseName ( ) const

Get the base name from a filename

Definition at line 227 of file xmipp_filename.cpp.

228 {
229  FileName baseName = removeLastExtension();
230  return baseName.afterLastOf("/");
231 }
FileName removeLastExtension() const
FileName afterLastOf(const String &str) const

◆ getBlockName()

String FileName::getBlockName ( ) const

Get blockName from filename

fn_meta="block1@md1.doc"
String blockName;
blockName=fn_meta.getblockName();//blockName="block1"

Definition at line 485 of file xmipp_filename.cpp.

486 {
487  size_t first = rfind(AT);
488  String result = "";
489  if (first != npos)
490  {
491  result = substr(0, first);
492  if ((first = result.find(COMMA)) != npos) // Assign and compare at the same time
493  result = result.substr(first+1);
494 
495  /* using isdigit instead of isalpha allows to
496  * detect as blockname rootnames starting by "/"
497  */
498  if (result.empty() || isdigit(result[0]))
499  result = "";
500  }
501  return result;
502 
503 }
glob_log first
#define COMMA
#define AT
std::string String
Definition: xmipp_strings.h:34

◆ getDecomposedFileName()

FileName FileName::getDecomposedFileName ( ) const

Get decomposed filename from filenames with . Mainly from selfiles

filename = fn_proj.decomposedFileName(); // fn_proj = "000001@g1ta000001.xmp"
// no=1
// filename = "g1ta000001.xmp"

Definition at line 147 of file xmipp_filename.cpp.

148 {
149  String str;
150  size_t no;
151  decompose(no, str);
152  return str;
153 }
void decompose(size_t &no, String &str) const
std::string String
Definition: xmipp_strings.h:34

◆ getDir()

FileName FileName::getDir ( ) const

Definition at line 235 of file xmipp_filename.cpp.

236 {
237  size_t pos = find_last_of("/");
238  return (FileName)( pos != npos ? substr(0, pos+1) : "");
239 }

◆ getExtension()

String FileName::getExtension ( ) const

Get the last extension from filename

The extension is returned without the dot. If there is no extension "" is returned.

String ext = fn_proj.get_extension();

Definition at line 242 of file xmipp_filename.cpp.

243 {
244  size_t posA = find_last_of("/");
245  size_t posB = find_last_of(".");
246  if (posB==npos)
247  return "";
248  if (posA==npos)
249  return substr(posB+1);
250  if (posB>posA)
251  return substr(posB+1);
252  return "";
253 }

◆ getFileFormat()

String FileName::getFileFormat ( ) const

Get image format identifier

fn_proj = "g1ta00001.xmp";
fn_proj = fn_proj.get_file_format(); // fn_proj == "xmp"
fn_proj = "g1ta00001.nor:spi";
fn_proj = fn_proj.get_file_format(); // fn_proj == "spi"
fn_proj = "input.file#120,120,55,1024,float";
fn_proj = fn_proj.get_file_format(); // fn_proj == "raw"

Definition at line 396 of file xmipp_filename.cpp.

397 {
398  size_t first;
399  FileName result;
400  if ((first = rfind(COLON)) != npos)
401  result = substr(first + 1);
402  else if ((first = rfind(".")) != npos)
403  {
404  // Get everything from the '.' to the end of the filename
405  // If there is a '#', only keep whatever is between the '.' and the '#'
406  result = substr(first + 1);
407  result = result.substr(0, result.find(NUM));
408  }
409  else if (find(NUM) != npos)
410  return "raw";
411  return result.toLowercase();
412 }
#define NUM
std::vector< SelLine >::iterator find(std::vector< SelLine > &text, const std::string &img_name)
Definition: selfile.cpp:553
glob_log first
FileName toLowercase() const
#define COLON

◆ getFiles()

void FileName::getFiles ( std::vector< FileName > &  files) const

Return the list of files if this filename is a directory

Definition at line 697 of file xmipp_filename.cpp.

698 {
699  files.clear();
700 
701  DIR *dp;
702  struct dirent *dirp;
703  if ((dp = opendir(c_str())) == NULL)
705 
706  while ((dirp = readdir(dp)) != NULL)
707  if (strcmp(dirp->d_name,".")!=0 && strcmp(dirp->d_name,"..")!=0)
708  files.push_back(FileName(dirp->d_name));
709  closedir(dp);
710  std::sort(files.begin(),files.end());
711 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
File or directory does not exist.
Definition: xmipp_error.h:136
void sort(struct DCEL_T *dcel)
Definition: sorting.cpp:18

◆ getFileSize()

size_t FileName::getFileSize ( ) const

Get the size of the file.

Definition at line 414 of file xmipp_filename.cpp.

415 {
416  Stat info;
417  if (stat(c_str(), &info))
418  {
419  char cCurrentPath[FILENAME_MAX];
420  char *success=getcwd(cCurrentPath, sizeof(cCurrentPath));
421  if (success==NULL)
422  cCurrentPath[0]='\0';
423  REPORT_ERROR(ERR_UNCLASSIFIED,formatString("FileName::getFileSize: Cannot get size of file %s/%s",cCurrentPath,this->c_str()));
424  }
425  return info.st_size;
426 
427 // int fd = open(c_str(), O_RDONLY);
428 // size_t size = lseek(fd, 0, SEEK_END); // seek to end of file
429 // close(fd);
430 //
431 // return size;
432 
433 }
Just to locate unclassified errors.
Definition: xmipp_error.h:192
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
#define FILENAME_MAX
Definition: defines.h:43
String formatString(const char *format,...)
struct stat Stat

◆ getNumber()

int FileName::getNumber ( ) const

Get the number from a filename

If there is no number a -1 is returned.

FileName proj("g1ta00001");
int num = proj.getNumber();

Definition at line 447 of file xmipp_filename.cpp.

448 {
449  size_t skip_directories = find_last_of("/") + 1;
450  size_t point = find_first_of(".", skip_directories);
451  if (point == npos)
452  point = length();
453  size_t root_end = find_last_not_of("0123456789", point - 1);
454  if (root_end + 1 != point)
455  {
456  if (point - root_end > FILENAMENUMBERLENGTH)
457  root_end = point - FILENAMENUMBERLENGTH - 1;
458  String aux = substr(root_end + 1, point - root_end + 1);
459  return atoi(aux.c_str());
460  }
461  else
462  return -1;
463 }
__host__ __device__ float length(float2 v)
std::string String
Definition: xmipp_strings.h:34
#define FILENAMENUMBERLENGTH

◆ getPrefixNumber()

size_t FileName::getPrefixNumber ( size_t  pos = 0) const

Get the number from a stack filename

If there is no number a 0 is returned.

FileName proj("24@images.stk");
size_t num = proj.getStackNumber();

Definition at line 466 of file xmipp_filename.cpp.

467 {
468  size_t first = rfind(AT);
469  size_t result = ALL_IMAGES;
470  if (first != npos)
471  {
472  std::vector<String> prefixes;
473  size_t nPref = splitString(substr(0, first),",",prefixes, false);
474 
475  if (pos > nPref-1)
476  REPORT_ERROR(ERR_ARG_INCORRECT, formatString("getPrefixNumber: Selected %lu position greater than %lu positions \n"
477  " detected in %s filename.",pos+1, nPref, this->c_str()));
478 
479  if (isdigit(prefixes[pos].at(0)))
480  result = textToSizeT(prefixes[pos].c_str());
481  }
482  return result;
483 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
glob_log first
int splitString(const String &input, const String &delimiter, StringVector &results, bool includeEmpties)
Incorrect argument received.
Definition: xmipp_error.h:113
#define AT
#define ALL_IMAGES
String formatString(const char *format,...)
size_t textToSizeT(const char *str)

◆ getRoot()

FileName FileName::getRoot ( ) const

Get the root from a filename

FileName fn_root, fn_proj("g1ta00001");
fn_root = fn_proj.get_root();

Definition at line 157 of file xmipp_filename.cpp.

158 {
159  size_t skip_directories = find_last_of("/") + 1;
160  size_t point = find_first_of(".", skip_directories);
161  if (point == npos)
162  point = length();
163  size_t root_end = find_last_not_of("0123456789", point - 1);
164  if (root_end + 1 != point)
165  if (point - root_end > FILENAMENUMBERLENGTH)
166  root_end = point - FILENAMENUMBERLENGTH - 1;
167  return substr(0, root_end + 1);
168 }
__host__ __device__ float length(float2 v)
#define FILENAMENUMBERLENGTH

◆ getString()

String FileName::getString ( ) const
inline

Convert to String

Definition at line 158 of file xmipp_filename.h.

159  {
160  return (String)(*this);
161  }
std::string String
Definition: xmipp_strings.h:34

◆ hasImageExtension()

bool FileName::hasImageExtension ( ) const

True if the extension of this filename is of an image type

Definition at line 256 of file xmipp_filename.cpp.

257 {
258  String ext = getFileFormat();
259  return (ext=="img" || ext=="hed" || ext=="inf" || ext=="raw" || ext=="mrc" ||
260  ext=="map" || ext=="spi" || ext=="xmp" || ext=="tif" || ext=="dm3" ||
261  ext=="spe" || ext=="em" || ext=="pif" || ext=="ser" || ext=="stk" ||
262  ext=="mrcs"|| ext=="jpg" || ext=="dm4");
263 }
std::string String
Definition: xmipp_strings.h:34
String getFileFormat() const

◆ hasMetadataExtension()

bool FileName::hasMetadataExtension ( ) const

True if the extension of this filename is of a metadata file

Definition at line 283 of file xmipp_filename.cpp.

284 {
285  String ext = getFileFormat();
286  return (ext == "sel" || ext == "xmd" || ext == "doc" ||
287  ext == "ctfdat" || ext == "ctfparam" || ext == "pos" ||
288  ext == "sqlite" || ext == "xml" || ext == "star");
289 }
std::string String
Definition: xmipp_strings.h:34
String getFileFormat() const

◆ hasStackExtension()

bool FileName::hasStackExtension ( ) const

True if the extension of this filename is of a stack type

Definition at line 266 of file xmipp_filename.cpp.

267 {
268  String ext = getFileFormat();
269  return (ext=="stk" || ext=="spi" || ext=="xmp" || ext=="mrcs" || ext=="mrc" ||
270  ext=="img" || ext=="hed" || ext=="pif" || ext=="tif" || ext=="dm3" ||
271  ext=="ser" || ext=="st" || ext=="dm4");
272 }
std::string String
Definition: xmipp_strings.h:34
String getFileFormat() const

◆ hasVolumeExtension()

bool FileName::hasVolumeExtension ( ) const

True if the extension of this filename is of a stack type

Definition at line 275 of file xmipp_filename.cpp.

276 {
277  String ext = getFileFormat();
278  return (ext=="vol" || ext=="spi" || ext=="xmp" || ext=="mrc" || ext=="map" ||
279  ext=="em" || ext=="pif" || ext=="inf" || ext=="raw");
280 }
std::string String
Definition: xmipp_strings.h:34
String getFileFormat() const

◆ initRandom()

void FileName::initRandom ( int  length)

Random name

Generate a random name of the desired length.

Definition at line 292 of file xmipp_filename.cpp.

293 {
295  *this = "";
296  for (int i = 0; i < length; i++)
297  *this += 'a' + FLOOR(rnd_unif(0, 26));
298 }
#define i
double rnd_unif()
#define FLOOR(x)
Definition: xmipp_macros.h:240
__host__ __device__ float length(float2 v)
unsigned int randomize_random_generator()

◆ initUniqueName()

void FileName::initUniqueName ( const char *  templateStr = "xmippTemp_XXXXXX",
const String fnDir = "" 
)

Unique name

Generate a unique name replacing each 'X' with a character from the portable filename character set. The characters are chosen such that the resulting name does not duplicate the name of an existing file.

Definition at line 301 of file xmipp_filename.cpp.

302 {
303 #ifndef __MINGW32__
304  int fd;
305  const int len=512;
306  char filename[len];
307  if (fnDir!="")
308  strcpy(filename,(fnDir+"/").c_str());
309  else
310  filename[0]=0;
311  strcat(filename, templateStr);
312  filename[len - 1] = 0;
313  if ((fd = mkstemp(filename)) == -1)
314  {
315  perror("FileName::Error generating tmp lock file");
316  exit(1);
317  }
318  close(fd);
319  *this = filename;
320 #endif
321 }
#define len

◆ insertBeforeExtension()

FileName FileName::insertBeforeExtension ( const String str) const

Insert before first extension

If there is no extension, the insertion is performed at the end.

fn_proj = "g1ta00001.xmp";
fn_proj = fn_proj.insert_before_extension("pp");
// fn_proj == "g1ta00001pp.xmp"
fn_proj = "g1ta00001";
fn_proj = fn_proj.insert_before_extension("pp");
// fn_proj=="g1ta00001pp"

Definition at line 358 of file xmipp_filename.cpp.

359 {
360  FileName retval = *this;
361  size_t pos = find_last_of('.');
362  return pos != npos ? retval.insert(pos, str) : retval.append(str);
363 }

◆ isDir()

bool FileName::isDir ( ) const

True if the path is a directory

Definition at line 714 of file xmipp_filename.cpp.

715 {
716  Stat st_buf;
717  if (stat (c_str(), &st_buf) != 0)
718  REPORT_ERROR(ERR_UNCLASSIFIED,(String)"Cannot determine status of filename "+ *this);
719  return (S_ISDIR (st_buf.st_mode));
720 }
Just to locate unclassified errors.
Definition: xmipp_error.h:192
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
std::string String
Definition: xmipp_strings.h:34
struct stat Stat

◆ isEmpty()

bool FileName::isEmpty ( ) const
inline

True if the FileName has an empty value ""

Definition at line 165 of file xmipp_filename.h.

166  {
167  return *this == "";
168  }

◆ isInStack()

bool FileName::isInStack ( ) const

True if this filename belongs to a stack

Definition at line 122 of file xmipp_filename.cpp.

123 {
124  return find(AT) != String::npos;
125 }
std::vector< SelLine >::iterator find(std::vector< SelLine > &text, const std::string &img_name)
Definition: selfile.cpp:553
#define AT

◆ isMetaData()

bool FileName::isMetaData ( bool  failIfNotExists = true) const

Is this file a MetaData file? Returns true if the get_file_format extension == "sel", "doc" or "xmd" Otherwise, the file is opened and checked for the occurrence of "XMIPP_3 *" in its first line

Definition at line 556 of file xmipp_filename.cpp.

557 {
558  //check empty string
559  if (empty())
560  REPORT_ERROR(ERR_ARG_INCORRECT, "FileName::isMetaData: Empty string is not a MetaData");
561  //file names containing : or % are not metadatas
562  //size_t found = this->find('@');
563  if (find_first_of(":#") != npos)
564  return false;
565 
566  //check if file exists
567  if (failIfNotExists && !existsTrim())
568  REPORT_ERROR(ERR_IO_NOTFILE, formatString("FileName::isMetaData: File: '%s' does not exist", c_str()));
569  //This is dangerous and should be removed
570  //in next version. only star1 files should be OK
571  //ROB
572  //FIXME
573  return (hasMetadataExtension() || isStar1(failIfNotExists));
574 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
bool existsTrim() const
It is not a file.
Definition: xmipp_error.h:141
Incorrect argument received.
Definition: xmipp_error.h:113
bool isStar1(bool failIfNotExists) const
String formatString(const char *format,...)
bool hasMetadataExtension() const

◆ isStar1()

bool FileName::isStar1 ( bool  failIfNotExists) const

True if it is a Star 1 file.

Definition at line 576 of file xmipp_filename.cpp.

577 {
578  std::ifstream infile( this->removeAllPrefixes().c_str(), std::ios_base::in);
579  String line;
580 
581  if (infile.fail())
582  {
583  if (failIfNotExists)
584  REPORT_ERROR( ERR_IO_NOTEXIST, formatString("File '%s' does not exist.", this->removeAllPrefixes().c_str()));
585  else
586  return false;
587  }
588 
589  // Search for xmipp_3,
590  char cline[128];
591  infile.getline(cline, 128);
592  infile.close();
593  line = cline;
594  size_t pos = line.find(METADATA_XMIPP_STAR);
595  return (pos != npos); // xmipp_star_1 token found
596 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
FileName removeAllPrefixes() const
int in
File or directory does not exist.
Definition: xmipp_error.h:136
std::string String
Definition: xmipp_strings.h:34
String formatString(const char *format,...)
#define METADATA_XMIPP_STAR

◆ makePath()

int FileName::makePath ( mode_t  mode = 0755) const

makePath - ensure all directories in path exist Algorithm takes the pessimistic view and works top-down to ensure each directory in path exists, rather than optimistically creating the last element and working backwards. Return null if fails

Definition at line 811 of file xmipp_filename.cpp.

812 {
813  char *pp;
814  char *sp;
815  int status;
816  char *copypath = strdup(c_str());
817  if (copypath == NULL)
818  REPORT_ERROR(ERR_MEM_BADREQUEST,"FileName::makePath: Canot alloc memory");
819 
820  status = 0;
821  pp = copypath;
822  while (status == 0 && (sp = strchr(pp, '/')) != 0)
823  {
824  if (sp != pp)
825  {
826  /* Neither root nor double slash in path */
827  *sp = '\0';
828  status = do_mkdir(copypath, mode);
829  *sp = '/';
830  }
831  pp = sp + 1;
832  }
833  if (status == 0)
834  status = do_mkdir(c_str(), mode);
835  free(copypath);
836  return status;
837 }
int do_mkdir(const char *path, mode_t mode)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
#define pp(s, x)
Definition: ml2d.cpp:473
Bad amount of memory requested.
Definition: xmipp_error.h:165
free((char *) ob)
void mode

◆ operator=()

FileName& FileName::operator= ( const FileName op)
inline

Assignment constructor

Definition at line 104 of file xmipp_filename.h.

105  {
106  return (FileName&) std::string::operator=(op);
107  }

◆ removeAllExtensions()

FileName FileName::removeAllExtensions ( ) const

Remove all extensions

Definition at line 382 of file xmipp_filename.cpp.

383 {
384  FileName retval = *this;
385  size_t first = find_last_of('/');
386  first = find_first_of('.', first + 1);
387  return (first == npos) ? retval: retval.substr(0, first);
388 }
glob_log first

◆ removeAllPrefixes()

FileName FileName::removeAllPrefixes ( ) const

Remove blockName or slice number from filename

fn_meta="block1@md1.doc"
String blockName;
filename=removeBlockNameOrSliceNumber();//filename="md1.doc"

Definition at line 548 of file xmipp_filename.cpp.

549 {
550  size_t first = rfind(AT);
551  if (first != npos)
552  return substr(first + 1);
553  return *this;
554 }
glob_log first
#define AT

◆ removeBlockName()

FileName FileName::removeBlockName ( ) const

Remove blockName from filename

fn_meta="block1@md1.doc"
String blockName;
filename=fn_meta.getblockName();//filename="md1.doc"

Definition at line 505 of file xmipp_filename.cpp.

506 {
507  size_t first = rfind(AT);
508 
509  if (first != npos)
510  {
511  String block = substr(0, first);
512  size_t second = block.find(COMMA);
513 
514  if (second == npos)
515  {
516  if (!isdigit(block[0])){
517  return substr(first + 1);
518  }
519  }
520  else
521  {
522  String prefix = block.substr(0, second);
523  block = block.substr(second + 1);
524  if (!isdigit(block[0]))
525  return prefix + substr(first);
526  }
527  }
528  return *this;
529 }
glob_log first
#define COMMA
#define AT
std::string String
Definition: xmipp_strings.h:34

◆ removeDirectories()

FileName FileName::removeDirectories ( int  keep = 0) const

Remove all directories

Or if keep>0, then keep the lowest keep directories

Definition at line 641 of file xmipp_filename.cpp.

642 {
643  size_t last_slash = rfind("/");
644  int tokeep = keep;
645  while (tokeep > 0)
646  {
647  last_slash = rfind("/", last_slash - 1);
648  tokeep--;
649  }
650  if (last_slash == npos)
651  return *this;
652  else
653  return substr(last_slash + 1, length() - last_slash);
654 }
__host__ __device__ float length(float2 v)

◆ removeExtension()

FileName FileName::removeExtension ( const String ext) const

Remove a certain extension

It doesn't matter if there are several extensions and the one to be removed is in the middle. If the given extension is not present in the filename nothing is done.

fn_proj = "g1ta00001.xmp.bak";
fn_proj = fn_proj.remove_extension("xmp");
// fn_proj == "g1ta00001.bak"

Definition at line 366 of file xmipp_filename.cpp.

367 {
368  FileName retval = *this;
369  size_t first = find((String) "." + ext);
370  return (first == npos) ? retval: retval.erase(first, 1 + ext.length());
371 }
std::vector< SelLine >::iterator find(std::vector< SelLine > &text, const std::string &img_name)
Definition: selfile.cpp:553
glob_log first
std::string String
Definition: xmipp_strings.h:34

◆ removeFileFormat()

FileName FileName::removeFileFormat ( ) const

Remove file format

fn_proj = "g1ta00001.xmp";
fn_proj = fn_proj.get_file_format(); // fn_proj == "xmp"
fn_proj = "g1ta00001.nor:spi";
fn_proj = fn_proj.get_file_format(); // fn_proj == "spi"
fn_proj = "input.file#d=f#x=120,120,55#h=1024";
fn_proj = fn_proj.get_file_format(); // fn_proj == "raw"

Definition at line 435 of file xmipp_filename.cpp.

436 {
437  size_t found = rfind(NUM);
438  if (found != String::npos)
439  return substr(0, found);
440  found = rfind(COLON);
441  if (found != String::npos)
442  return substr(0, found);
443  return *this;
444 }
#define NUM
#define COLON

◆ removeFilename()

FileName FileName::removeFilename ( ) const

Extract the directory portion from a filename string (e.g. /foo/bar.txt -> /foo).

Definition at line 390 of file xmipp_filename.cpp.

391 {
392  size_t first = find_last_of('/');
393  return (first == npos) ? "" : substr(0, first);
394 }
glob_log first

◆ removeLastExtension()

FileName FileName::removeLastExtension ( ) const

Definition at line 374 of file xmipp_filename.cpp.

375 {
376  FileName retval = *this;
377  size_t first = find_last_of('.');
378  return (first == npos) ? retval : retval.substr(0, first);
379 }
glob_log first

◆ removePrefixNumber()

FileName FileName::removePrefixNumber ( ) const

Remove leading number from filename

fn_meta="1@md1.doc"
String blockName;
filename=fn_meta.removeSliceNumber();//filename="md1.doc"

Definition at line 531 of file xmipp_filename.cpp.

532 {
533  size_t first = rfind(AT);
534 
535  if (first != npos)
536  {
537  std::vector<String> prefixes;
538  int nPref = splitString(substr(0, first),",",prefixes, false);
539 
540  if (isdigit(prefixes[nPref-1].at(0)))
541  return substr(first + 1);
542  else if (nPref > 1) // isalpha and we remove the ","
543  return substr(first - prefixes[nPref-1].size());
544  }
545  return *this;
546 }
glob_log first
int splitString(const String &input, const String &delimiter, StringVector &results, bool includeEmpties)
#define AT

◆ removeSubstring()

FileName FileName::removeSubstring ( const String sub) const

Remove a substring from the filename

If the substring is not present the same FileName is returned, if it is there the substring is removed. It is equivalent to replaceSubstring(sub, "");

Definition at line 625 of file xmipp_filename.cpp.

626 {
627  return replaceSubstring(sub, "");
628 }
FileName replaceSubstring(const String &subOld, const String &subNew) const

◆ removeUntilPrefix()

FileName FileName::removeUntilPrefix ( const String prefix) const

Remove until prefix

Remove the starting string until the given prefix, inclusively. For instance /usr/local/data/ctf-image00001.fft with ctf- yields image00001.fft. If the prefix is not found nothing is done.

Definition at line 631 of file xmipp_filename.cpp.

632 {
633  size_t pos = find(prefix);
634  if (pos == npos)
635  return *this;
636  FileName result = *this;
637  return result.erase(0, pos + prefix.length());
638 }
std::vector< SelLine >::iterator find(std::vector< SelLine > &text, const std::string &img_name)
Definition: selfile.cpp:553

◆ replaceCharacter()

FileName FileName::replaceCharacter ( char  oldChar,
char  newChar 
) const

Replace all occurrences of a character by another character

Definition at line 611 of file xmipp_filename.cpp.

612 {
613  FileName result = *this;
614  std::replace(result.begin(), result.end(), oldChar, newChar);
615  return result;
616 }

◆ replaceExtension()

FileName FileName::replaceExtension ( const String newExt) const

Substitute last extension by a new one

fn_proj = "g1ta00001.xmp.bak";
fn_proj = fn_proj.replaceExtension("bor");
// fn_proj == "g1ta00001.xmp.bor"

Definition at line 619 of file xmipp_filename.cpp.

620 {
621  return removeLastExtension() + "." + newExt;
622 }
FileName removeLastExtension() const

◆ replaceSubstring()

FileName FileName::replaceSubstring ( const String subOld,
const String subNew 
) const

Replace a the first occurrence of substring 'subOld' by 'subNew' If 'subOld' not present, not changes are done. The search is done from left to right

fn_proj = "g1ta00001.xmp.bak";
fn_proj = fn_proj.replace(".xmp", ".bor");
// fn_proj == "g1ta00001.bor.bak"
fn_proj = "g1ta00001.xmp.bak";
fn_proj = fn_proj.replace(".bor", "");
// fn_proj == "g1ta00001.bak"

Definition at line 599 of file xmipp_filename.cpp.

600 {
601  size_t pos = find(subOld);
602  if (pos == npos)
603  return *this;
604 
605  FileName result = *this;
606  result.replace(pos, subOld.length(), subNew);
607  return result;
608 }
std::vector< SelLine >::iterator find(std::vector< SelLine > &text, const std::string &img_name)
Definition: selfile.cpp:553

◆ toLowercase()

FileName FileName::toLowercase ( ) const

Change all characters for lowercases

FileName fn_proj("g1tA00001");
fn_proj = fn_proj.to_lowercase(); // fn_proj = "g1ta00001"

Definition at line 171 of file xmipp_filename.cpp.

172 {
173  FileName result = *this;
174  for (size_t i = 0; i < result.length(); i++)
175  result[i] = tolower(result[i]);
176  return result;
177 }
#define i

◆ toUppercase()

FileName FileName::toUppercase ( ) const

Change all characters for uppercases

FileName fn_proj("g1tA00001");
fn_proj = fn_proj.to_uppercase(); // fn_proj = "G1Ta00001"

Definition at line 180 of file xmipp_filename.cpp.

181 {
182  FileName result = *this;
183  for (size_t i = 0; i < result.length(); i++)
184  result[i] = toupper(result[i]);
185  return result;
186 }
#define i

◆ waitUntilStableSize()

void FileName::waitUntilStableSize ( size_t  time_step = 250000)

Waits until the given filename has a stable size

The stable size is defined as having the same size within two samples separated by time_step (microsecs).

An exception is throw if the file exists but its size cannot be stated.

Definition at line 723 of file xmipp_filename.cpp.

724 {
725  size_t idx;
726  FileName basicName;
727  decompose(idx, basicName);
728 
729  if (!exists())
730  return;
731  Stat info1, info2;
732  if (stat(basicName.c_str(), &info1))
734  (String)"FileName::waitUntilStableSize: Cannot get size of file " + *this);
735  off_t size1 = info1.st_size;
736  do
737  {
738  usleep(time_step);
739  if (stat(basicName.c_str(), &info2))
741  (String)"FileName::waitUntilStableSize: Cannot get size of file " + *this);
742  off_t size2 = info2.st_size;
743  if (size1 == size2)
744  break;
745  size1 = size2;
746  }
747  while (true);
748  return;
749 }
Just to locate unclassified errors.
Definition: xmipp_error.h:192
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
void decompose(size_t &no, String &str) const
bool exists() const
std::string String
Definition: xmipp_strings.h:34
struct stat Stat

◆ withoutExtension()

FileName FileName::withoutExtension ( ) const

Remove last extension, if any

fn_proj = "g1ta00001.xmp";
fn_proj = fn_proj.without_extension(); // fn_proj == "g1ta00001"
fn_proj = "g1ta00001";
fn_proj = fn_proj.without_extension(); // fn_proj == "g1ta00001"

Definition at line 345 of file xmipp_filename.cpp.

346 {
347  FileName retval = *this;
348  return retval.substr(0, rfind("."));
349 }

◆ withoutRoot()

FileName FileName::withoutRoot ( ) const

Remove the root

fn_proj = "g1ta00001.xmp";
fn_proj = fn_proj.without_root(); // fn_proj == "00001.xmp"
fn_proj = "g1ta00001";
fn_proj = fn_proj.without_root(); // fn_proj == "00001"

Definition at line 352 of file xmipp_filename.cpp.

353 {
354  return removeSubstring(getRoot());
355 }
FileName getRoot() const
FileName removeSubstring(const String &sub) const

The documentation for this class was generated from the following files: