GlobalObjects
Alle Klassen Namensbereiche Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Freundbeziehungen Makrodefinitionen Seiten
EuFileHelper.h
gehe zur Dokumentation dieser Datei
1#ifndef INC_EuFILEHELPER_H
2#define INC_EuFILEHELPER_H
3//-----------------------------------------------------------------------------
68//-----------------------------------------------------------------------------
69#include <EuToolTypes.h>
70#include <string>
71#include <fstream>
72#include <vector>
73
74#if defined(_MSC_VER)
75# if _HAS_CXX17
76# include <filesystem>
77 namespace fs = std::filesystem;
78# define _HAS_FILESYSTEM
79# endif // _HAS_CXX17
80#elif defined(__MINGW32__) || defined(__MINGW64__)
81# if defined __has_include
82# if __has_include (<experimental/filesystem>)
83# include <experimental/filesystem>
84 namespace fs = std::experimental::filesystem;
85# define _HAS_FILESYSTEM
86# elif __has_include (<filesystem>)
87# include <filesystem>
88 namespace fs = std::filesystem;
89# define _HAS_FILESYSTEM
90# endif
91# endif
92# include <windows.h>
93#elif defined(__GNUC__)
94# if defined __has_include
95# if __has_include (<experimental/filesystem>)
96# include <experimental/filesystem>
97 namespace fs = std::experimental::filesystem;
98# define _HAS_FILESYSTEM
99# elif __has_include (<filesystem>)
100# include <filesystem>
101 namespace fs = std::filesystem;
102# define _HAS_FILESYSTEM
103# endif
104# endif
105#endif
106//-----------------------------------------------------------------------------
107namespace eut
108{
109 //---------------------------------------------------------------------------
110 // Forwards
111 #ifdef __EUFILEHELPER_WITH_EUBLOB
112 class Blob;
113 #endif //__EUFILEHELPER_WITH_EUBLOB
114 //---------------------------------------------------------------------------
150 namespace FileHelper
151 {
152 //============= Static-Methoden
153 //-------------------------------------------------------------------------
155
173 __tool_export_dll int storeFile( char * pszData,
174 std::streamsize nSize,
175 const std::string & rsFileName );
176 //#if defined(_MSC_VER) || defined(__MINGW32__)
177 __tool_export_dll int storeFile( char * pszData,
178 std::streamsize nSize,
179 const std::wstring & rsFileName );
180 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
182 //-------------------------------------------------------------------------
199 __tool_export_dll int storeFile( const std::string & rsStr,
200 const std::string & rsFileName );
201 //-------------------------------------------------------------------------
202 #if defined(_MSC_VER)
203 //-------------------------------------------------------------------------
222 __tool_export_dll int lockFile( std::ofstream *& prLockFile,
223 const std::string & rsLockFileName );
224 //-------------------------------------------------------------------------
225 #elif defined(__MINGW32__) || defined(__MINGW64__)
226 //-------------------------------------------------------------------------
246 __tool_export_dll int lockFile( void *& prLockFileHandle,
247 const std::string & rsLockFileName );
248 //-------------------------------------------------------------------------
249 #elif defined(__GNUC__)
250 //-------------------------------------------------------------------------
277 __tool_export_dll int lockFile( int & riLockFileHandle,
278 const std::string & rsLockFileName );
279 //-------------------------------------------------------------------------
280 #endif // defined(_MSC_VER) <> defined(__MINGW32__) || defined(__MINGW64__) <> defined(__GNUC__)
281 //-------------------------------------------------------------------------
282 #ifdef __EUFILEHELPER_WITH_EUBLOB
283 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
285
305 __tool_export_dll int storeFile( const Blob * pBlob,
306 const std::string & rsFileName );
307 //#if defined(_MSC_VER) || defined(__MINGW32__)
308 __tool_export_dll int storeFile( const Blob * pBlob,
309 const std::wstring & rsFileName );
310 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
312 //-------------------------------------------------------------------------
314
334 __tool_export_dll int storeFile( const Blob & rBlob,
335 const std::string & rsFileName );
336 //#if defined(_MSC_VER) || defined(__MINGW32__)
337 __tool_export_dll int storeFile( const Blob & rBlob,
338 const std::wstring & rsFileName );
339 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
341 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
342 #endif // __EUFILEHELPER_WITH_EUBLOB
343 //-------------------------------------------------------------------------
345
370 __tool_export_dll int loadFile( char *& prszData,
371 std::streamsize & rnSize,
372 const std::string & rsFileName,
373 bool bText = false );
374 //#if defined(_MSC_VER) || defined(__MINGW32__)
375 __tool_export_dll int loadFile( char *& prszData,
376 std::streamsize & rnSize,
377 const std::wstring & rsFileName,
378 bool bText = false );
379 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
381 //-------------------------------------------------------------------------
397 __tool_export_dll int loadFile( std::string & rstr,
398 const std::string & rsFileName );
399 //-------------------------------------------------------------------------
400 #ifdef __EUFILEHELPER_WITH_EUBLOB
401 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
403
429 const std::string & rsFileName );
430 //#if defined(_MSC_VER) || defined(__MINGW32__)
432 const std::wstring & rsFileName );
433 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
435 //-------------------------------------------------------------------------
437
461 const std::string & rsFileName );
462 //#if defined(_MSC_VER) || defined(__MINGW32__)
464 const std::wstring & rsFileName );
465 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
467 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
468 #endif // __EUFILEHELPER_WITH_EUBLOB
469 //-------------------------------------------------------------------------
471
500 __tool_export_dll int openInputFile( std::ifstream *& pInputFileStream,
501 const std::string & rsFileName );
502 //#if defined(_MSC_VER) || defined(__MINGW32__)
503 __tool_export_dll int openInputFile( std::ifstream *& pInputFileStream,
504 const std::wstring & rsFileName );
505 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
507 //-------------------------------------------------------------------------
509
538 __tool_export_dll int openInputFile( std::wifstream *& pInputFileStream,
539 const std::string & rsFileName );
540 //#if defined(_MSC_VER) || defined(__MINGW32__)
541 __tool_export_dll int openInputFile( std::wifstream *& pInputFileStream,
542 const std::wstring & rsFileName );
543 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
545 //-------------------------------------------------------------------------
547
574 __tool_export_dll int openOutputFile( std::ofstream *& pOutputFileStream,
575 const std::string & rsFileName );
576 //#if defined(_MSC_VER) || defined(__MINGW32__)
577 __tool_export_dll int openOutputFile( std::ofstream *& pOutputFileStream,
578 const std::wstring & rsFileName );
579 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
581 //-------------------------------------------------------------------------
583
610 __tool_export_dll int openOutputFile( std::wofstream *& pOutputFileStream,
611 const std::string & rsFileName );
612 //#if defined(_MSC_VER) || defined(__MINGW32__)
613 __tool_export_dll int openOutputFile( std::wofstream *& pOutputFileStream,
614 const std::wstring & rsFileName );
615 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
617 //-------------------------------------------------------------------------
637 __tool_export_dll int closeInputFile( std::ifstream *& pFileStream );
638 //-------------------------------------------------------------------------
658 __tool_export_dll int closeInputFile( std::wifstream *& pFileStream );
659 //-------------------------------------------------------------------------
679 __tool_export_dll int closeOutputFile( std::ofstream *& pFileStream );
680 //-------------------------------------------------------------------------
700 __tool_export_dll int closeOutputFile( std::wofstream *& pFileStream );
701 //-------------------------------------------------------------------------
703
720 __tool_export_dll int makeDir( const std::string & rsNewPath );
721 #ifdef _HAS_FILESYSTEM
722 __tool_export_dll int makeDir( const std::wstring & rsNewPath );
723 #endif //_HAS_FILESYSTEM
725 //-------------------------------------------------------------------------
727
742 __tool_export_dll int makePath( const std::string & rsNewPath );
743 #ifdef _HAS_FILESYSTEM
744 __tool_export_dll int makePath( const std::wstring & rsNewPath );
745 #endif //_HAS_FILESYSTEM
747 //-------------------------------------------------------------------------
766 __tool_export_dll int dirExist( const std::string & rsCheckPath );
767 //-------------------------------------------------------------------------
784 __tool_export_dll int dirExist( const std::wstring & rsCheckPath );
785 //-------------------------------------------------------------------------
798 //-------------------------------------------------------------------------
811 //-------------------------------------------------------------------------
827 __tool_export_dll int fileExist( const std::string & rsFullFileName );
828 //-------------------------------------------------------------------------
844 __tool_export_dll int fileExist( const std::wstring & rsFullFileName );
845 //-------------------------------------------------------------------------
871 __tool_export_dll int copyFile( const std::string & rsSourceFileName,
872 const std::string & rsTargetFileName );
873 //-------------------------------------------------------------------------
875
900 __tool_export_dll void splitPath( const std::string & rsFullFileName,
901 std::string & rsDrive,
902 std::string & rsPath,
903 std::string & rsFileName,
904 std::string & rsFileExtension );
905 #ifdef _HAS_FILESYSTEM
906 __tool_export_dll void splitPath( const std::wstring & rsFullFileName,
907 std::wstring & rsDrive,
908 std::wstring & rsPath,
909 std::wstring & rsFileName,
910 std::wstring & rsFileExtension );
911 #endif //_HAS_FILESYSTEM
913 //-------------------------------------------------------------------------
914 #ifndef _HAS_FILESYSTEM
915 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
959 __tool_export_dll void splitPath( const char * pszFullFileName,
960 char * pszDrive,
961 char * pszPath,
962 char * pszFileName,
963 char * pszFileExtension );
964 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
965 #endif // _HAS_FILESYSTEM
966 //-------------------------------------------------------------------------
967 #ifdef _HAS_FILESYSTEM
968 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
988 typedef void (*PROCESSING_FILE_MEMBERPTR)( const fs::path & rFullFileName );
989 //-------------------------------------------------------------------------
1007 typedef void (*PROCESSING_DIR_MEMBERPTR)( const fs::path & rFullPathName );
1008 //-------------------------------------------------------------------------
1009 #ifdef _MSC_VER
1010 // warning C4100: "rFullFileName": Unreferenzierter formaler Parameter
1011 #pragma warning( disable : 4100 )
1012 #endif
1013 //-------------------------------------------------------------------------
1014 #if defined(__GNUC__)
1015 // Warnung: unused parameter 'rFullFileName' [-Wunused-parameter]
1016 #pragma GCC diagnostic push
1017 #pragma GCC diagnostic ignored "-Wunused-parameter"
1018 #endif
1019 //-------------------------------------------------------------------------
1037 {
1038 public:
1039 //-----------------------------------------------------------------------
1055 virtual void processFileFount( const fs::path & rFullFileName ){};
1056 //-----------------------------------------------------------------------
1070 virtual void processDirFount( const fs::path & rFullPathName ){};
1071 //-----------------------------------------------------------------------
1072 };
1073 //-------------------------------------------------------------------------
1074 #if defined(__GNUC__)
1075 // Warnung: unused parameter 'rFullFileName' [-Wunused-parameter]
1076 #pragma GCC diagnostic pop
1077 #endif
1078 //-------------------------------------------------------------------------
1079 #ifdef _MSC_VER
1080 // warning C4100: "rFullFileName": Unreferenzierter formaler Parameter
1081 #pragma warning( default : 4100 )
1082 #endif
1083 //-------------------------------------------------------------------------
1084 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1085 #endif // _HAS_FILESYSTEM
1086 //-------------------------------------------------------------------------
1103 __tool_export_dll int deleteFile( const std::string & rsFullFileName );
1104 //-------------------------------------------------------------------------
1105 #ifdef _HAS_FILESYSTEM
1106 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
1107 //-------------------------------------------------------------------------
1128 __tool_export_dll int deleteFile( const fs::path & rFullFileName );
1129 //-------------------------------------------------------------------------
1175 __tool_export_dll void deleteFileForIterateDirectory( const fs::path & rFullFileName );
1176 //-------------------------------------------------------------------------
1217 int _iterateDirectory( const fs::path & rIterPath,
1218 bool bRecursive,
1219 PROCESSING_FILE_MEMBERPTR ProcessingFileFunction,
1220 PROCESSING_DIR_MEMBERPTR ProcessingDirFunction,
1221 CallBackFileDirFount * pProcessingObject );
1222 //-------------------------------------------------------------------------
1256 __tool_export_dll int iterateDirectory( const fs::path & rIterPath,
1257 bool bRecursive,
1258 PROCESSING_FILE_MEMBERPTR ProcessingFileFunction,
1259 PROCESSING_DIR_MEMBERPTR ProcessingDirFunction );
1260 //---------------------------------------------------------------------------
1291 __tool_export_dll int iterateDirectory( const fs::path & rIterPath,
1292 bool bRecursive,
1293 CallBackFileDirFount & rProcessingObject );
1294 //-------------------------------------------------------------------------
1296
1322 __tool_export_dll void getFullFileName( std::string & rsFullFileName,
1323 const fs::path & rFileSystemPath,
1324 const char & rSeparator = '/' );
1325 __tool_export_dll void getFullFileName( std::wstring & rsFullFileName,
1326 const fs::path & rFileSystemPath,
1327 const std::wstring & rSeparator = L"/" );
1329 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1330 #endif // _HAS_FILESYSTEM
1331 //-------------------------------------------------------------------------
1332 #ifdef __EUFILEHELPER_WITH_EUBLOB
1333 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
1335
1360 int _getswapDatavalue( std::string & sOutText,
1361 const std::string & sInText,
1362 const std::string & sTextOrFile );
1363 int _getswapDatavalue( std::string & sOutText,
1364 const std::wstring & sInText,
1365 const std::string & sTextOrFile );
1367 //-------------------------------------------------------------------------
1369
1477 __tool_export_dll int swapDataInFile( std::vector< std::string > & rParamVector, bool bSimulate = false );
1478 //#if ( defined(_MSC_VER) || defined(__MINGW32__) ) && (__cplusplus >= 201103L) && defined(_HAS_FILESYSTEM)
1479 #if (__cplusplus >= 201103L) && defined(_HAS_FILESYSTEM)
1480 __tool_export_dll int swapDataInFile( std::vector< std::wstring > & rParamVector, bool bSimulate = false );
1481 //#endif // ( defined(_MSC_VER) || defined(__MINGW32__) ) && (d__cplusplus >= 201103L) && defined(_HAS_FILESYSTEM)
1482 #endif // (d__cplusplus >= 201103L) && defined(_HAS_FILESYSTEM)
1484 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1485 #endif // __EUFILEHELPER_WITH_EUBLOB
1486 //-------------------------------------------------------------------------
1487 };
1488 //---------------------------------------------------------------------------
1489} // namespace eut
1490#endif
Für jede Bibliothek, hier 'EuTools' gibt es eine Typen-Datei.
#define __tool_export_dll
Definition EuToolTypes.h:94
Diese Klasse erlaubt das Bearbeiten eines Blobs (einfügen, kopieren, durchsuchen etc....
Definition EuBlob.h:92
Definition EuFileHelper.h:1037
virtual void processDirFount(const fs::path &rFullPathName)
Definition EuFileHelper.h:1070
virtual void processFileFount(const fs::path &rFullFileName)
Definition EuFileHelper.h:1055
Helfer mit statischen Methoden zur Bearbeitung des Filesystems.
Definition EuFileHelper.h:151
__tool_export_dll int closeOutputFile(std::ofstream *&pFileStream)
void(* PROCESSING_DIR_MEMBERPTR)(const fs::path &rFullPathName)
Definition EuFileHelper.h:1007
__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:988
__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:79