Xmipp  v3.23.11-Nereus
Functions | Variables
xmipp_filename.cpp File Reference
#include <algorithm>
#include <dirent.h>
#include <fstream>
#include <stdio.h>
#include <unistd.h>
#include "xmipp_filename.h"
#include "xmipp_funcs.h"
#include "xmipp_image_macros.h"
#include "xmipp_image_generic.h"
#include <sys/stat.h>
Include dependency graph for xmipp_filename.cpp:

Go to the source code of this file.

Functions

void setMetadataVersion (String version)
 
String getMetadataVersion (void)
 
int do_mkdir (const char *path, mode_t mode)
 
char * getXmippPath ()
 
char * getXmippSrcPath ()
 
void copyImage (const FileName &source, const FileName &target)
 
void deleteFile (const FileName &fn)
 

Variables

String FileNameVersion =METADATA_XMIPP_STAR
 

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

◆ do_mkdir()

int do_mkdir ( const char *  path,
mode_t  mode 
)

Auxiliary function used to create a tree of directories return 0 on success

Definition at line 785 of file xmipp_filename.cpp.

786 {
787  Stat st;
788  int status = 0;
789 
790  if (stat(path, &st) != 0)
791  {
792  /* Directory does not exist */
793 #ifndef __MINGW32__
794  if (mkdir(path, mode) != 0)
795 #else
796 
797  if (mkdir(path) != 0)
798 #endif
799 
800  status = -1;
801  }
802  else if (!S_ISDIR(st.st_mode))
803  {
804  errno = ENOTDIR;
805  status = -1;
806  }
807 
808  return (status);
809 }
void mode
struct stat Stat

◆ 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 =METADATA_XMIPP_STAR

Definition at line 39 of file xmipp_filename.cpp.