GlobalObjects
Lade ...
Suche ...
Keine Treffer
EuFileHelper.h
gehe zur Dokumentation dieser Datei
1#ifndef INC_EuFILEHELPER_H
2#define INC_EuFILEHELPER_H
3//-----------------------------------------------------------------------------
36//-----------------------------------------------------------------------------
37#include <EuToolTypes.h>
38#include <string>
39#include <fstream>
40#include <vector>
41
42#if defined(_MSC_VER)
43# if _HAS_CXX17
44# include <filesystem>
45 namespace fs = std::filesystem;
46# define _HAS_FILESYSTEM
47# endif // _HAS_CXX17
48#elif defined(__MINGW32__) || defined(__MINGW64__)
49# if defined __has_include
50# if __has_include (<filesystem>)
51# include <filesystem>
52 namespace fs = std::filesystem;
53# define _HAS_FILESYSTEM
54# elif __has_include (<experimental/filesystem>)
55# include <experimental/filesystem>
56 namespace fs = std::experimental::filesystem;
57# define _HAS_FILESYSTEM
58# endif
59# endif
60# include <windows.h>
61#elif defined(__GNUC__)
62# if (__cplusplus >= 201103L && __cplusplus < 202102)
63# include <experimental/filesystem>
64 namespace fs = std::experimental::filesystem;
65# define _HAS_FILESYSTEM
66# endif
67#endif
68//-----------------------------------------------------------------------------
69namespace eut
70{
71 //---------------------------------------------------------------------------
72 // Forwards
73 #ifdef __EUFILEHELPER_WITH_EUBLOB
74 class Blob;
75 #endif //__EUFILEHELPER_WITH_EUBLOB
76 //---------------------------------------------------------------------------
112 namespace FileHelper
113 {
114 //============= Static-Methoden
115 //-------------------------------------------------------------------------
117
135 __tool_export_dll int storeFile( char * pszData,
136 std::streamsize nSize,
137 const std::string & rsFileName );
138 //#if defined(_MSC_VER) || defined(__MINGW32__)
139 __tool_export_dll int storeFile( char * pszData,
140 std::streamsize nSize,
141 const std::wstring & rsFileName );
142 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
144 //-------------------------------------------------------------------------
161 __tool_export_dll int storeFile( const std::string & rsStr,
162 const std::string & rsFileName );
163 //-------------------------------------------------------------------------
164 #if defined(_MSC_VER)
165 //-------------------------------------------------------------------------
184 __tool_export_dll int lockFile( std::ofstream *& prLockFile,
185 const std::string & rsLockFileName );
186 //-------------------------------------------------------------------------
187 #elif defined(__MINGW32__) || defined(__MINGW64__)
188 //-------------------------------------------------------------------------
208 __tool_export_dll int lockFile( void *& prLockFileHandle,
209 const std::string & rsLockFileName );
210 //-------------------------------------------------------------------------
211 #elif defined(__GNUC__)
212 //-------------------------------------------------------------------------
239 __tool_export_dll int lockFile( int & riLockFileHandle,
240 const std::string & rsLockFileName );
241 //-------------------------------------------------------------------------
242 #endif // defined(_MSC_VER) <> defined(__MINGW32__) || defined(__MINGW64__) <> defined(__GNUC__)
243 //-------------------------------------------------------------------------
244 #ifdef __EUFILEHELPER_WITH_EUBLOB
245 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
247
267 __tool_export_dll int storeFile( const Blob * pBlob,
268 const std::string & rsFileName );
269 //#if defined(_MSC_VER) || defined(__MINGW32__)
270 __tool_export_dll int storeFile( const Blob * pBlob,
271 const std::wstring & rsFileName );
272 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
274 //-------------------------------------------------------------------------
276
296 __tool_export_dll int storeFile( const Blob & rBlob,
297 const std::string & rsFileName );
298 //#if defined(_MSC_VER) || defined(__MINGW32__)
299 __tool_export_dll int storeFile( const Blob & rBlob,
300 const std::wstring & rsFileName );
301 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
303 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
304 #endif // __EUFILEHELPER_WITH_EUBLOB
305 //-------------------------------------------------------------------------
307
332 __tool_export_dll int loadFile( char *& prszData,
333 std::streamsize & rnSize,
334 const std::string & rsFileName,
335 bool bText = false );
336 //#if defined(_MSC_VER) || defined(__MINGW32__)
337 __tool_export_dll int loadFile( char *& prszData,
338 std::streamsize & rnSize,
339 const std::wstring & rsFileName,
340 bool bText = false );
341 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
343 //-------------------------------------------------------------------------
359 __tool_export_dll int loadFile( std::string & rstr,
360 const std::string & rsFileName );
361 //-------------------------------------------------------------------------
362 #ifdef __EUFILEHELPER_WITH_EUBLOB
363 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
365
391 const std::string & rsFileName );
392 //#if defined(_MSC_VER) || defined(__MINGW32__)
394 const std::wstring & rsFileName );
395 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
397 //-------------------------------------------------------------------------
399
423 const std::string & rsFileName );
424 //#if defined(_MSC_VER) || defined(__MINGW32__)
426 const std::wstring & rsFileName );
427 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
429 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
430 #endif // __EUFILEHELPER_WITH_EUBLOB
431 //-------------------------------------------------------------------------
433
462 __tool_export_dll int openInputFile( std::ifstream *& pInputFileStream,
463 const std::string & rsFileName );
464 //#if defined(_MSC_VER) || defined(__MINGW32__)
465 __tool_export_dll int openInputFile( std::ifstream *& pInputFileStream,
466 const std::wstring & rsFileName );
467 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
469 //-------------------------------------------------------------------------
471
500 __tool_export_dll int openInputFile( std::wifstream *& pInputFileStream,
501 const std::string & rsFileName );
502 //#if defined(_MSC_VER) || defined(__MINGW32__)
503 __tool_export_dll int openInputFile( std::wifstream *& pInputFileStream,
504 const std::wstring & rsFileName );
505 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
507 //-------------------------------------------------------------------------
509
536 __tool_export_dll int openOutputFile( std::ofstream *& pOutputFileStream,
537 const std::string & rsFileName );
538 //#if defined(_MSC_VER) || defined(__MINGW32__)
539 __tool_export_dll int openOutputFile( std::ofstream *& pOutputFileStream,
540 const std::wstring & rsFileName );
541 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
543 //-------------------------------------------------------------------------
545
572 __tool_export_dll int openOutputFile( std::wofstream *& pOutputFileStream,
573 const std::string & rsFileName );
574 //#if defined(_MSC_VER) || defined(__MINGW32__)
575 __tool_export_dll int openOutputFile( std::wofstream *& pOutputFileStream,
576 const std::wstring & rsFileName );
577 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
579 //-------------------------------------------------------------------------
599 __tool_export_dll int closeInputFile( std::ifstream *& pFileStream );
600 //-------------------------------------------------------------------------
620 __tool_export_dll int closeInputFile( std::wifstream *& pFileStream );
621 //-------------------------------------------------------------------------
641 __tool_export_dll int closeOutputFile( std::ofstream *& pFileStream );
642 //-------------------------------------------------------------------------
662 __tool_export_dll int closeOutputFile( std::wofstream *& pFileStream );
663 //-------------------------------------------------------------------------
665
682 __tool_export_dll int makeDir( const std::string & rsNewPath );
683 #ifdef _HAS_FILESYSTEM
684 __tool_export_dll int makeDir( const std::wstring & rsNewPath );
685 #endif //_HAS_FILESYSTEM
687 //-------------------------------------------------------------------------
689
704 __tool_export_dll int makePath( const std::string & rsNewPath );
705 #ifdef _HAS_FILESYSTEM
706 __tool_export_dll int makePath( const std::wstring & rsNewPath );
707 #endif //_HAS_FILESYSTEM
709 //-------------------------------------------------------------------------
728 __tool_export_dll int dirExist( const std::string & rsCheckPath );
729 //-------------------------------------------------------------------------
746 __tool_export_dll int dirExist( const std::wstring & rsCheckPath );
747 //-------------------------------------------------------------------------
760 //-------------------------------------------------------------------------
773 //-------------------------------------------------------------------------
789 __tool_export_dll int fileExist( const std::string & rsFullFileName );
790 //-------------------------------------------------------------------------
806 __tool_export_dll int fileExist( const std::wstring & rsFullFileName );
807 //-------------------------------------------------------------------------
833 __tool_export_dll int copyFile( const std::string & rsSourceFileName,
834 const std::string & rsTargetFileName );
835 //-------------------------------------------------------------------------
837
862 __tool_export_dll void splitPath( const std::string & rsFullFileName,
863 std::string & rsDrive,
864 std::string & rsPath,
865 std::string & rsFileName,
866 std::string & rsFileExtension );
867 #ifdef _HAS_FILESYSTEM
868 __tool_export_dll void splitPath( const std::wstring & rsFullFileName,
869 std::wstring & rsDrive,
870 std::wstring & rsPath,
871 std::wstring & rsFileName,
872 std::wstring & rsFileExtension );
873 #endif //_HAS_FILESYSTEM
875 //-------------------------------------------------------------------------
876 #ifndef _HAS_FILESYSTEM
877 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
921 __tool_export_dll void splitPath( const char * pszFullFileName,
922 char * pszDrive,
923 char * pszPath,
924 char * pszFileName,
925 char * pszFileExtension );
926 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
927 #endif // _HAS_FILESYSTEM
928 //-------------------------------------------------------------------------
929 #ifdef _HAS_FILESYSTEM
930 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
950 typedef void (*PROCESSING_FILE_MEMBERPTR)( const fs::path & rFullFileName );
951 //-------------------------------------------------------------------------
969 typedef void (*PROCESSING_DIR_MEMBERPTR)( const fs::path & rFullPathName );
970 //-------------------------------------------------------------------------
971 #ifdef _MSC_VER
972 // warning C4100: "rFullFileName": Unreferenzierter formaler Parameter
973 #pragma warning( disable : 4100 )
974 #endif
975 //-------------------------------------------------------------------------
976 #if defined(__GNUC__)
977 // Warnung: unused parameter 'rFullFileName' [-Wunused-parameter]
978 #pragma GCC diagnostic push
979 #pragma GCC diagnostic ignored "-Wunused-parameter"
980 #endif
981 //-------------------------------------------------------------------------
999 {
1000 public:
1001 //-----------------------------------------------------------------------
1017 virtual void processFileFount( const fs::path & rFullFileName ){};
1018 //-----------------------------------------------------------------------
1032 virtual void processDirFount( const fs::path & rFullPathName ){};
1033 //-----------------------------------------------------------------------
1034 };
1035 //-------------------------------------------------------------------------
1036 #if defined(__GNUC__)
1037 // Warnung: unused parameter 'rFullFileName' [-Wunused-parameter]
1038 #pragma GCC diagnostic pop
1039 #endif
1040 //-------------------------------------------------------------------------
1041 #ifdef _MSC_VER
1042 // warning C4100: "rFullFileName": Unreferenzierter formaler Parameter
1043 #pragma warning( default : 4100 )
1044 #endif
1045 //-------------------------------------------------------------------------
1046 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1047 #endif // _HAS_FILESYSTEM
1048 //-------------------------------------------------------------------------
1065 __tool_export_dll int deleteFile( const std::string & rsFullFileName );
1066 //-------------------------------------------------------------------------
1067 #ifdef _HAS_FILESYSTEM
1068 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
1069 //-------------------------------------------------------------------------
1090 __tool_export_dll int deleteFile( const fs::path & rFullFileName );
1091 //-------------------------------------------------------------------------
1137 __tool_export_dll void deleteFileForIterateDirectory( const fs::path & rFullFileName );
1138 //-------------------------------------------------------------------------
1179 int _iterateDirectory( const fs::path & rIterPath,
1180 bool bRecursive,
1181 PROCESSING_FILE_MEMBERPTR ProcessingFileFunction,
1182 PROCESSING_DIR_MEMBERPTR ProcessingDirFunction,
1183 CallBackFileDirFount * pProcessingObject );
1184 //-------------------------------------------------------------------------
1218 __tool_export_dll int iterateDirectory( const fs::path & rIterPath,
1219 bool bRecursive,
1220 PROCESSING_FILE_MEMBERPTR ProcessingFileFunction,
1221 PROCESSING_DIR_MEMBERPTR ProcessingDirFunction );
1222 //---------------------------------------------------------------------------
1253 __tool_export_dll int iterateDirectory( const fs::path & rIterPath,
1254 bool bRecursive,
1255 CallBackFileDirFount & rProcessingObject );
1256 //-------------------------------------------------------------------------
1258
1284 __tool_export_dll void getFullFileName( std::string & rsFullFileName,
1285 const fs::path & rFileSystemPath,
1286 const char & rSeparator = '/' );
1287 __tool_export_dll void getFullFileName( std::wstring & rsFullFileName,
1288 const fs::path & rFileSystemPath,
1289 const std::wstring & rSeparator = L"/" );
1291 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1292 #endif // _HAS_FILESYSTEM
1293 //-------------------------------------------------------------------------
1294 #ifdef __EUFILEHELPER_WITH_EUBLOB
1295 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
1297
1322 int _getswapDatavalue( std::string & sOutText,
1323 const std::string & sInText,
1324 const std::string & sTextOrFile );
1325 int _getswapDatavalue( std::string & sOutText,
1326 const std::wstring & sInText,
1327 const std::string & sTextOrFile );
1329 //-------------------------------------------------------------------------
1331
1439 __tool_export_dll int swapDataInFile( std::vector< std::string > & rParamVector, bool bSimulate = false );
1440 //#if ( defined(_MSC_VER) || defined(__MINGW32__) ) && (__cplusplus >= 201103L) && defined(_HAS_FILESYSTEM)
1441 #if (__cplusplus >= 201103L) && defined(_HAS_FILESYSTEM)
1442 __tool_export_dll int swapDataInFile( std::vector< std::wstring > & rParamVector, bool bSimulate = false );
1443 //#endif // ( defined(_MSC_VER) || defined(__MINGW32__) ) && (d__cplusplus >= 201103L) && defined(_HAS_FILESYSTEM)
1444 #endif // (d__cplusplus >= 201103L) && defined(_HAS_FILESYSTEM)
1446 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1447 #endif // __EUFILEHELPER_WITH_EUBLOB
1448 //-------------------------------------------------------------------------
1449 };
1450 //---------------------------------------------------------------------------
1451} // namespace eut
1452#endif
Für jede Bibliothek, hier 'EuTools' gibt es eine Typen-Datei.
#define __tool_export_dll
Definition EuToolTypes.h:63
Diese Klasse erlaubt das Bearbeiten eines Blobs (einfügen, kopieren, durchsuchen etc....
Definition EuBlob.h:60
Definition EuFileHelper.h:999
virtual void processDirFount(const fs::path &rFullPathName)
Definition EuFileHelper.h:1032
virtual void processFileFount(const fs::path &rFullFileName)
Definition EuFileHelper.h:1017
__tool_export_dll int closeOutputFile(std::ofstream *&pFileStream)
void(* PROCESSING_DIR_MEMBERPTR)(const fs::path &rFullPathName)
Definition EuFileHelper.h:969
__tool_export_dll int copyFile(const std::string &rsSourceFileName, const std::string &rsTargetFileName)
__tool_export_dll int lockFile(std::ofstream *&prLockFile, const std::string &rsLockFileName)
__tool_export_dll int closeInputFile(std::ifstream *&pFileStream)
__tool_export_dll int loadFile(char *&prszData, std::streamsize &rnSize, const std::string &rsFileName, bool bText=false)
Liefert den Inhalt und die Größe einer Datei aus dem Filesystem.
void(* PROCESSING_FILE_MEMBERPTR)(const fs::path &rFullFileName)
Definition EuFileHelper.h:950
__tool_export_dll void splitPath(const std::string &rsFullFileName, std::string &rsDrive, std::string &rsPath, std::string &rsFileName, std::string &rsFileExtension)
Erwartet einen Dateinamen inkl.
__tool_export_dll void deleteFileForIterateDirectory(const fs::path &rFullFileName)
__tool_export_dll std::string getCurrentWorkingDirAsString()
__tool_export_dll std::wstring getCurrentWorkingDirAsWString()
int _iterateDirectory(const fs::path &rIterPath, bool bRecursive, PROCESSING_FILE_MEMBERPTR ProcessingFileFunction, PROCESSING_DIR_MEMBERPTR ProcessingDirFunction, CallBackFileDirFount *pProcessingObject)
int _getswapDatavalue(std::string &sOutText, const std::string &sInText, const std::string &sTextOrFile)
Hilfsfunktion für swapDataInFile (...) die einen Wert in einem std::string liefert,...
__tool_export_dll int dirExist(const std::string &rsCheckPath)
__tool_export_dll int iterateDirectory(const fs::path &rIterPath, bool bRecursive, PROCESSING_FILE_MEMBERPTR ProcessingFileFunction, PROCESSING_DIR_MEMBERPTR ProcessingDirFunction)
__tool_export_dll int openInputFile(std::ifstream *&pInputFileStream, const std::string &rsFileName)
Liefert eine geöffnete Datei vom Typ std::ifstream zum Schreiben im Filesystem.
__tool_export_dll void getFullFileName(std::string &rsFullFileName, const fs::path &rFileSystemPath, const char &rSeparator='/')
Setzt im übergebenen String den vollen Dateinamen aus dem übergebenen fs::path, auch wenn dieser nur ...
__tool_export_dll int fileExist(const std::string &rsFullFileName)
__tool_export_dll int makeDir(const std::string &rsNewPath)
Kreiert übergebene(s) Verzeichnis(se).
__tool_export_dll int deleteFile(const std::string &rsFullFileName)
__tool_export_dll int openOutputFile(std::ofstream *&pOutputFileStream, const std::string &rsFileName)
Liefert eine geöffnete Datei vom Typ std::ofstream zum Lesen im Filesystem.
__tool_export_dll int swapDataInFile(std::vector< std::string > &rParamVector, bool bSimulate=false)
Sucht und ersetzt Inhalte in Dateien und speichert diese ggf.
__tool_export_dll int makePath(const std::string &rsNewPath)
Kreiert übergebene(s) Verzeichnis(se).
__tool_export_dll int storeFile(char *pszData, std::streamsize nSize, const std::string &rsFileName)
Speichert Daten in eine Datei im Filesystem.
Definition IniFile.h:47