19#ifndef MS_FILEUTILITIES_HPP
20#define MS_FILEUTILITIES_HPP
35namespace matrix_science {
36 class ms_mascotoptions;
43#if defined(_MSC_VER) && (_MSC_VER < 1300)
44#define OFFSET64_C(c) c ## i64
46#define OFFSET64_C(c) c ## LL
48 typedef INT64 OFFSET64_T;
50#define OFFSET64_C(c) c ## LL
51 typedef off_t OFFSET64_T;
67 static time_t getLastModificationTime(
const char* filename,
ms_errs* err = NULL);
70 static void setLastModificationTime(
const char* filename, time_t modificationTime,
ms_errs* err = NULL);
73 static UINT64 getFileSize(
const char* filename,
ms_errs* err = NULL);
76 static std::string findMascotDat(
const char *szMascotDatFilename,
78 const int timeoutSec = 0 );
81 static bool doesFileExist(
const char* filename);
83 static bool isFileWritable(
const char * filePath);
98 err_sar setAccessRights(
const char * filename,
103 const bool avoid_reapply =
false);
104 unsigned long getSARExtendedErrorCode()
const;
107 static bool isDirectory(
const char * path);
111 static int createDirectory(
const std::string & directory, std::string & errorDirectory);
113 static int createDirectory(
const std::string & directory, std::string & OUTPUT);
116 static int deleteDirectory(
const std::string & directory,
const bool bDeleteSubdirectories =
true);
119 bool findOpen(
const std::string directory,
120 const std::string wildcard);
123 bool findNext(std::string & fileName);
129 static std::string stripLastFolder(
const std::string pathname);
132 static std::string getMD5Sum(
const std::string &str,
const bool b32bitEncoding =
true);
136 CMD_ARGUMENT_PARSE_OK = 0,
137 CMD_ARGUMENT_PARSE_UNBALANCED = -1,
138 CMD_ARGUMENT_PARSE_COLLISION = -2,
139 CMD_ARGUMENT_PARSE_INVALIDCHAR = -3,
143 static int parseCommandLineArgumentString(
const std::string &command, std::vector<std::string> &components);
147 CMPXML_NO_FLAG = 0x0000,
148 CMPXML_IGN_DBL_IDENTICAL = 0x0001,
149 CMPXML_IGN_DBL_DIFF_100_PPM = 0x0002,
150 CMPXML_IGN_DBL_DIFF_10_PPM = 0x0004,
151 CMPXML_IGN_DBL_DIFF_1_PPM = 0x0008,
152 CMPXML_IGN_DBL_MASK = (CMPXML_IGN_DBL_IDENTICAL | CMPXML_IGN_DBL_DIFF_100_PPM | CMPXML_IGN_DBL_DIFF_10_PPM | CMPXML_IGN_DBL_DIFF_1_PPM),
154 CMPXML_STRIP_TRAILING_ZEROS = 0x0010,
155 CMPXML_IGN_COL_SIZE_EQ_ONE = 0x0020,
156 CMPXML_IGN_TODAY_DATE = 0x0040,
157 CMPXML_IGN_INF_999999 = 0x0080,
158 CMPXML_IGN_FILE_URL = 0x0100,
159 CMPXML_IGN_RAWFILE_NAME = 0x0200,
165 static bool compareXmlFiles(
const std::string & filePath1,
166 const std::string & filePath2,
167 const std::string & schemaPath,
169 const std::vector<std::string> & ignoreElements,
170 const std::vector<std::string> & ignoreAttributes,
172 std::string & differences,
173 std::string & lhsOnly,
174 std::string & rhsOnly);
176 static bool compareXmlFiles(
const std::string & filePath1,
177 const std::string & filePath2,
178 const std::string & schemaPath,
180 const std::vector<std::string> & ignoreElements,
181 const std::vector<std::string> & ignoreAttributes,
183 std::string & OUTPUT,
184 std::string & OUTPUT,
185 std::string & OUTPUT);
188 static std::string getCacheDirectory(
const std::string& resFilePath,
189 const std::string& cacheDirPattern,
190 std::string& fileNameNoPath,
194 unsigned long errorCode_;
196#if defined(_MSC_VER) && (_MSC_VER < 1300)
197 struct _finddata_t fileFindInfo_;
200 struct __finddata64_t fileFindInfo_;
201 intptr_t fileFindPtr_;
206 std::string fileFindWildcard_;
207 std::string fileFindDirectory_;
209 static CMD_ARGUMENT_PARSE_RESULT splitCommandString(
const std::string &command,
const std::string::size_type j1,
const std::string::size_type j2, std::vector<std::string> &argvstr);
211 static const std::string ws_delims_;
212 static const char begin_quote_ =
'"';
213 static const char end_quote_ =
'"';
214 static const std::string invalid_chars_;
All errors are collected in an instance of this class.
Definition: ms_errors.hpp:37
This utility class mainly contains static members.
Definition: ms_fileutilities.hpp:61
compareXMLFiles_flags
Flags for the compareXmlFiles() function.
Definition: ms_fileutilities.hpp:146
CMD_ARGUMENT_PARSE_RESULT
Return status from parseCommandLineArgumentString().
Definition: ms_fileutilities.hpp:135
err_sar
setAccessRights() return value.
Definition: ms_fileutilities.hpp:86
@ SAR_FAIL_SET_ENTRIES_IN_ACL
Error returned by call to SetEntriesInAcl().
Definition: ms_fileutilities.hpp:90
@ SAR_SUCCESS
Success!
Definition: ms_fileutilities.hpp:87
@ SAR_FAIL_GET_NAMED_SECURITY_INFO
Error returned by call to GetNamedSecurityInfo().
Definition: ms_fileutilities.hpp:89
@ SAR_FAIL_CHMOD
Error returned by call to chmod().
Definition: ms_fileutilities.hpp:88
@ SAR_FAIL_SET_NAMED_SECURITY_INFO
Error returned by call to SetNamedSecurityInfo().
Definition: ms_fileutilities.hpp:91
An instance of this class represents all the parameters specified in the Options section of mascot....
Definition: ms_mascotoptions.hpp:91