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//-----------------------------------------------------------------------------
51//-----------------------------------------------------------------------------
52#include <EuToolTypes.h>
53#include <string>
54#include <fstream>
55#include <vector>
56
57#if defined(_MSC_VER)
58# if _HAS_CXX17
59# include <filesystem>
60 namespace fs = std::filesystem;
61# define _HAS_FILESYSTEM
62# endif // _HAS_CXX17
63#elif defined(__MINGW32__) || defined(__MINGW64__)
64# if defined __has_include
65# if __has_include (<filesystem>)
66# include <filesystem>
67 namespace fs = std::filesystem;
68# define _HAS_FILESYSTEM
69# elif __has_include (<experimental/filesystem>)
70# include <experimental/filesystem>
71 namespace fs = std::experimental::filesystem;
72# define _HAS_FILESYSTEM
73# endif
74# endif
75# include <windows.h>
76#elif defined(__GNUC__)
77# if defined __has_include
78# if __has_include (<filesystem>)
79# include <filesystem>
80 namespace fs = std::filesystem;
81# define _HAS_FILESYSTEM
82# endif
83# endif
84#endif
85//-----------------------------------------------------------------------------
86namespace eut
87{
88 //---------------------------------------------------------------------------
89 // Forwards
90 #ifdef __EUFILEHELPER_WITH_EUBLOB
91 class Blob;
92 #endif //__EUFILEHELPER_WITH_EUBLOB
93 //---------------------------------------------------------------------------
129 namespace FileHelper
130 {
131 //============= Static-Methoden
132 //-------------------------------------------------------------------------
134
152 __tool_export_dll int storeFile( char * pszData,
153 std::streamsize nSize,
154 const std::string & rsFileName );
155 //#if defined(_MSC_VER) || defined(__MINGW32__)
156 __tool_export_dll int storeFile( char * pszData,
157 std::streamsize nSize,
158 const std::wstring & rsFileName );
159 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
161 //-------------------------------------------------------------------------
178 __tool_export_dll int storeFile( const std::string & rsStr,
179 const std::string & rsFileName );
180 //-------------------------------------------------------------------------
181 #if defined(_MSC_VER)
182 //-------------------------------------------------------------------------
201 __tool_export_dll int lockFile( std::ofstream *& prLockFile,
202 const std::string & rsLockFileName );
203 //-------------------------------------------------------------------------
204 #elif defined(__MINGW32__) || defined(__MINGW64__)
205 //-------------------------------------------------------------------------
225 __tool_export_dll int lockFile( void *& prLockFileHandle,
226 const std::string & rsLockFileName );
227 //-------------------------------------------------------------------------
228 #elif defined(__GNUC__)
229 //-------------------------------------------------------------------------
256 __tool_export_dll int lockFile( int & riLockFileHandle,
257 const std::string & rsLockFileName );
258 //-------------------------------------------------------------------------
259 #endif // defined(_MSC_VER) <> defined(__MINGW32__) || defined(__MINGW64__) <> defined(__GNUC__)
260 //-------------------------------------------------------------------------
261 #ifdef __EUFILEHELPER_WITH_EUBLOB
262 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
264
284 __tool_export_dll int storeFile( const Blob * pBlob,
285 const std::string & rsFileName );
286 //#if defined(_MSC_VER) || defined(__MINGW32__)
287 __tool_export_dll int storeFile( const Blob * pBlob,
288 const std::wstring & rsFileName );
289 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
291 //-------------------------------------------------------------------------
293
313 __tool_export_dll int storeFile( const Blob & rBlob,
314 const std::string & rsFileName );
315 //#if defined(_MSC_VER) || defined(__MINGW32__)
316 __tool_export_dll int storeFile( const Blob & rBlob,
317 const std::wstring & rsFileName );
318 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
320 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
321 #endif // __EUFILEHELPER_WITH_EUBLOB
322 //-------------------------------------------------------------------------
324
349 __tool_export_dll int loadFile( char *& prszData,
350 std::streamsize & rnSize,
351 const std::string & rsFileName,
352 bool bText = false );
353 //#if defined(_MSC_VER) || defined(__MINGW32__)
354 __tool_export_dll int loadFile( char *& prszData,
355 std::streamsize & rnSize,
356 const std::wstring & rsFileName,
357 bool bText = false );
358 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
360 //-------------------------------------------------------------------------
376 __tool_export_dll int loadFile( std::string & rstr,
377 const std::string & rsFileName );
378 //-------------------------------------------------------------------------
379 #ifdef __EUFILEHELPER_WITH_EUBLOB
380 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
382
408 const std::string & rsFileName );
409 //#if defined(_MSC_VER) || defined(__MINGW32__)
411 const std::wstring & rsFileName );
412 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
414 //-------------------------------------------------------------------------
416
440 const std::string & rsFileName );
441 //#if defined(_MSC_VER) || defined(__MINGW32__)
443 const std::wstring & rsFileName );
444 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
446 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
447 #endif // __EUFILEHELPER_WITH_EUBLOB
448 //-------------------------------------------------------------------------
450
479 __tool_export_dll int openInputFile( std::ifstream *& pInputFileStream,
480 const std::string & rsFileName );
481 //#if defined(_MSC_VER) || defined(__MINGW32__)
482 __tool_export_dll int openInputFile( std::ifstream *& pInputFileStream,
483 const std::wstring & rsFileName );
484 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
486 //-------------------------------------------------------------------------
488
517 __tool_export_dll int openInputFile( std::wifstream *& pInputFileStream,
518 const std::string & rsFileName );
519 //#if defined(_MSC_VER) || defined(__MINGW32__)
520 __tool_export_dll int openInputFile( std::wifstream *& pInputFileStream,
521 const std::wstring & rsFileName );
522 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
524 //-------------------------------------------------------------------------
526
553 __tool_export_dll int openOutputFile( std::ofstream *& pOutputFileStream,
554 const std::string & rsFileName );
555 //#if defined(_MSC_VER) || defined(__MINGW32__)
556 __tool_export_dll int openOutputFile( std::ofstream *& pOutputFileStream,
557 const std::wstring & rsFileName );
558 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
560 //-------------------------------------------------------------------------
562
589 __tool_export_dll int openOutputFile( std::wofstream *& pOutputFileStream,
590 const std::string & rsFileName );
591 //#if defined(_MSC_VER) || defined(__MINGW32__)
592 __tool_export_dll int openOutputFile( std::wofstream *& pOutputFileStream,
593 const std::wstring & rsFileName );
594 //#endif // defined(_MSC_VER) || defined(__MINGW32__)
596 //-------------------------------------------------------------------------
616 __tool_export_dll int closeInputFile( std::ifstream *& pFileStream );
617 //-------------------------------------------------------------------------
637 __tool_export_dll int closeInputFile( std::wifstream *& pFileStream );
638 //-------------------------------------------------------------------------
658 __tool_export_dll int closeOutputFile( std::ofstream *& pFileStream );
659 //-------------------------------------------------------------------------
679 __tool_export_dll int closeOutputFile( std::wofstream *& pFileStream );
680 //-------------------------------------------------------------------------
682
699 __tool_export_dll int makeDir( const std::string & rsNewPath );
700 #ifdef _HAS_FILESYSTEM
701 __tool_export_dll int makeDir( const std::wstring & rsNewPath );
702 #endif //_HAS_FILESYSTEM
704 //-------------------------------------------------------------------------
706
721 __tool_export_dll int makePath( const std::string & rsNewPath );
722 #ifdef _HAS_FILESYSTEM
723 __tool_export_dll int makePath( const std::wstring & rsNewPath );
724 #endif //_HAS_FILESYSTEM
726 //-------------------------------------------------------------------------
745 __tool_export_dll int dirExist( const std::string & rsCheckPath );
746 //-------------------------------------------------------------------------
763 __tool_export_dll int dirExist( const std::wstring & rsCheckPath );
764 //-------------------------------------------------------------------------
777 //-------------------------------------------------------------------------
790 //-------------------------------------------------------------------------
806 __tool_export_dll int fileExist( const std::string & rsFullFileName );
807 //-------------------------------------------------------------------------
823 __tool_export_dll int fileExist( const std::wstring & rsFullFileName );
824 //-------------------------------------------------------------------------
850 __tool_export_dll int copyFile( const std::string & rsSourceFileName,
851 const std::string & rsTargetFileName );
852 //-------------------------------------------------------------------------
854
879 __tool_export_dll void splitPath( const std::string & rsFullFileName,
880 std::string & rsDrive,
881 std::string & rsPath,
882 std::string & rsFileName,
883 std::string & rsFileExtension );
884 #ifdef _HAS_FILESYSTEM
885 __tool_export_dll void splitPath( const std::wstring & rsFullFileName,
886 std::wstring & rsDrive,
887 std::wstring & rsPath,
888 std::wstring & rsFileName,
889 std::wstring & rsFileExtension );
890 #endif //_HAS_FILESYSTEM
892 //-------------------------------------------------------------------------
893 #ifndef _HAS_FILESYSTEM
894 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
938 __tool_export_dll void splitPath( const char * pszFullFileName,
939 char * pszDrive,
940 char * pszPath,
941 char * pszFileName,
942 char * pszFileExtension );
943 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
944 #endif // _HAS_FILESYSTEM
945 //-------------------------------------------------------------------------
946 #ifdef _HAS_FILESYSTEM
947 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
967 typedef void (*PROCESSING_FILE_MEMBERPTR)( const fs::path & rFullFileName );
968 //-------------------------------------------------------------------------
986 typedef void (*PROCESSING_DIR_MEMBERPTR)( const fs::path & rFullPathName );
987 //-------------------------------------------------------------------------
988 #ifdef _MSC_VER
989 // warning C4100: "rFullFileName": Unreferenzierter formaler Parameter
990 #pragma warning( disable : 4100 )
991 #endif
992 //-------------------------------------------------------------------------
993 #if defined(__GNUC__)
994 // Warnung: unused parameter 'rFullFileName' [-Wunused-parameter]
995 #pragma GCC diagnostic push
996 #pragma GCC diagnostic ignored "-Wunused-parameter"
997 #endif
998 //-------------------------------------------------------------------------
1016 {
1017 public:
1018 //-----------------------------------------------------------------------
1034 virtual void processFileFount( const fs::path & rFullFileName ){};
1035 //-----------------------------------------------------------------------
1049 virtual void processDirFount( const fs::path & rFullPathName ){};
1050 //-----------------------------------------------------------------------
1051 };
1052 //-------------------------------------------------------------------------
1053 #if defined(__GNUC__)
1054 // Warnung: unused parameter 'rFullFileName' [-Wunused-parameter]
1055 #pragma GCC diagnostic pop
1056 #endif
1057 //-------------------------------------------------------------------------
1058 #ifdef _MSC_VER
1059 // warning C4100: "rFullFileName": Unreferenzierter formaler Parameter
1060 #pragma warning( default : 4100 )
1061 #endif
1062 //-------------------------------------------------------------------------
1063 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1064 #endif // _HAS_FILESYSTEM
1065 //-------------------------------------------------------------------------
1082 __tool_export_dll int deleteFile( const std::string & rsFullFileName );
1083 //-------------------------------------------------------------------------
1084 #ifdef _HAS_FILESYSTEM
1085 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
1086 //-------------------------------------------------------------------------
1107 __tool_export_dll int deleteFile( const fs::path & rFullFileName );
1108 //-------------------------------------------------------------------------
1154 __tool_export_dll void deleteFileForIterateDirectory( const fs::path & rFullFileName );
1155 //-------------------------------------------------------------------------
1196 int _iterateDirectory( const fs::path & rIterPath,
1197 bool bRecursive,
1198 PROCESSING_FILE_MEMBERPTR ProcessingFileFunction,
1199 PROCESSING_DIR_MEMBERPTR ProcessingDirFunction,
1200 CallBackFileDirFount * pProcessingObject );
1201 //-------------------------------------------------------------------------
1235 __tool_export_dll int iterateDirectory( const fs::path & rIterPath,
1236 bool bRecursive,
1237 PROCESSING_FILE_MEMBERPTR ProcessingFileFunction,
1238 PROCESSING_DIR_MEMBERPTR ProcessingDirFunction );
1239 //---------------------------------------------------------------------------
1270 __tool_export_dll int iterateDirectory( const fs::path & rIterPath,
1271 bool bRecursive,
1272 CallBackFileDirFount & rProcessingObject );
1273 //-------------------------------------------------------------------------
1275
1301 __tool_export_dll void getFullFileName( std::string & rsFullFileName,
1302 const fs::path & rFileSystemPath,
1303 const char & rSeparator = '/' );
1304 __tool_export_dll void getFullFileName( std::wstring & rsFullFileName,
1305 const fs::path & rFileSystemPath,
1306 const std::wstring & rSeparator = L"/" );
1308 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1309 #endif // _HAS_FILESYSTEM
1310 //-------------------------------------------------------------------------
1311 #ifdef __EUFILEHELPER_WITH_EUBLOB
1312 //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
1314
1339 int _getswapDatavalue( std::string & sOutText,
1340 const std::string & sInText,
1341 const std::string & sTextOrFile );
1342 int _getswapDatavalue( std::string & sOutText,
1343 const std::wstring & sInText,
1344 const std::string & sTextOrFile );
1346 //-------------------------------------------------------------------------
1348
1456 __tool_export_dll int swapDataInFile( std::vector< std::string > & rParamVector, bool bSimulate = false );
1457 //#if ( defined(_MSC_VER) || defined(__MINGW32__) ) && (__cplusplus >= 201103L) && defined(_HAS_FILESYSTEM)
1458 #if (__cplusplus >= 201103L) && defined(_HAS_FILESYSTEM)
1459 __tool_export_dll int swapDataInFile( std::vector< std::wstring > & rParamVector, bool bSimulate = false );
1460 //#endif // ( defined(_MSC_VER) || defined(__MINGW32__) ) && (d__cplusplus >= 201103L) && defined(_HAS_FILESYSTEM)
1461 #endif // (d__cplusplus >= 201103L) && defined(_HAS_FILESYSTEM)
1463 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1464 #endif // __EUFILEHELPER_WITH_EUBLOB
1465 //-------------------------------------------------------------------------
1466 };
1467 //---------------------------------------------------------------------------
1468} // namespace eut
1469#endif
Für jede Bibliothek, hier 'EuTools' gibt es eine Typen-Datei.
#define __tool_export_dll
Definition EuToolTypes.h:77
Diese Klasse erlaubt das Bearbeiten eines Blobs (einfügen, kopieren, durchsuchen etc....
Definition EuBlob.h:75
Definition EuFileHelper.h:1016
virtual void processDirFount(const fs::path &rFullPathName)
Definition EuFileHelper.h:1049
virtual void processFileFount(const fs::path &rFullFileName)
Definition EuFileHelper.h:1034
Helfer mit statischen Methoden zur Bearbeitung des Filesystems.
Definition EuFileHelper.h:130
__tool_export_dll int closeOutputFile(std::ofstream *&pFileStream)
void(* PROCESSING_DIR_MEMBERPTR)(const fs::path &rFullPathName)
Definition EuFileHelper.h:986
__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:967
__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:62