Xmipp  v3.23.11-Nereus
Classes | Macros | Typedefs
xmipp_filename.h File Reference
#include <unistd.h>
#include "xmipp_strings.h"
#include <fcntl.h>
Include dependency graph for xmipp_filename.h:

Go to the source code of this file.

Classes

class  FileName
 
class  FileNameComparison
 
class  FileLock
 

Macros

#define FILENAMENUMBERLENGTH   6
 
#define METADATA_XMIPP_STAR   "# XMIPP_STAR_1"
 
#define METADATA_XMIPP_SQLITE   "SQLite format 3"
 
#define AT   '@'
 
#define COMMA   ','
 
#define COLON   ':'
 
#define NUM   '#'
 

Typedefs

typedef struct stat Stat
 
String FileNameVersion
 
char * getXmippPath ()
 
char * getXmippSrcPath ()
 
bool fileExists (const char *filename)
 
bool fileExists (const FileName &filename)
 
void copyImage (const FileName &source, const FileName &target)
 
void deleteFile (const FileName &fn)
 
void setMetadataVersion (String version)
 
String getMetadataVersion (void)
 

Macro Definition Documentation

◆ AT

#define AT   '@'

Some filename macros

Definition at line 52 of file xmipp_filename.h.

◆ COLON

#define COLON   ':'

Definition at line 54 of file xmipp_filename.h.

◆ COMMA

#define COMMA   ','

Definition at line 53 of file xmipp_filename.h.

◆ FILENAMENUMBERLENGTH

#define FILENAMENUMBERLENGTH   6

Definition at line 39 of file xmipp_filename.h.

◆ METADATA_XMIPP_SQLITE

#define METADATA_XMIPP_SQLITE   "SQLite format 3"

Definition at line 48 of file xmipp_filename.h.

◆ METADATA_XMIPP_STAR

#define METADATA_XMIPP_STAR   "# XMIPP_STAR_1"

Definition at line 47 of file xmipp_filename.h.

◆ NUM

#define NUM   '#'

Definition at line 55 of file xmipp_filename.h.

Typedef Documentation

◆ Stat

typedef struct stat Stat

Definition at line 41 of file xmipp_filename.h.

Function Documentation

◆ copyImage()

void copyImage ( const FileName source,
const FileName target 
)

Copy one image

Definition at line 872 of file xmipp_filename.cpp.

873 {
874  ImageGeneric img(source);
875  img.write(target);
876 }

◆ deleteFile()

void deleteFile ( const FileName fn)

Delete file

Definition at line 878 of file xmipp_filename.cpp.

879 {
880  fn.deleteFile();
881 }
void deleteFile() const

◆ fileExists() [1/2]

bool fileExists ( const char *  filename)
inline

Check if the file exists using the stat function

Definition at line 696 of file xmipp_filename.h.

697 {
698  // do not use stat since updates the atime flag. This may be dangerous
699  // for mpi processes in which the same file is accessed many times
700  // from different computers even if not writting is made
701  //return ( stat(filename, &buffer) == 0 ? true : false );
702  return ( access (filename, F_OK) == 0 ? true : false);
703 
704 }

◆ fileExists() [2/2]

bool fileExists ( const FileName filename)
inline

Check if the file exists using the stat function

Definition at line 708 of file xmipp_filename.h.

709 {
710  return fileExists(filename.c_str());
711 }
bool fileExists(const char *filename)

◆ getMetadataVersion()

String getMetadataVersion ( void  )

Definition at line 46 of file xmipp_filename.cpp.

47 {
48  return FileNameVersion;
49 }
String FileNameVersion

◆ getXmippPath()

char* getXmippPath ( )

Returns the base directory of the Xmipp installation

Definition at line 853 of file xmipp_filename.cpp.

854 {
855  char* path = getenv("XMIPP_HOME");
856  if (path == NULL)
857  REPORT_ERROR(ERR_VALUE_EMPTY, "getXmippPath::Variable XMIPP_HOME is not defined");
858  return path;
859 
860 }
Empty value.
Definition: xmipp_error.h:194
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211

◆ getXmippSrcPath()

char* getXmippSrcPath ( )

Returns the source directory of Xmipp

Definition at line 863 of file xmipp_filename.cpp.

864 {
865  char* path = getenv("XMIPP_SRC");
866  if (path == NULL)
867  REPORT_ERROR(ERR_VALUE_EMPTY, "getXmippSrcPath::Variable XMIPP_HOME is not defined");
868  return path;
869 
870 }
Empty value.
Definition: xmipp_error.h:194
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211

◆ setMetadataVersion()

void setMetadataVersion ( String  version)

Definition at line 41 of file xmipp_filename.cpp.

42 {
43  FileNameVersion=version;
44 }
String FileNameVersion

Variable Documentation

◆ FileNameVersion

String FileNameVersion

Definition at line 39 of file xmipp_filename.cpp.