From eff5b7c31ca132cf69a8676822a006114e8f4dc2 Mon Sep 17 00:00:00 2001 From: Dinand Vanvelzen Date: Sun, 7 Jul 2024 15:36:32 -0500 Subject: [PATCH] New service, initial version: FileSorter This is a service which auto sorts files based on type and timestamps. Could potentially later be enhanced to also consider meta-data native to specific types Note that while its a service, currently the dir watching inbox functionality is not yet implemented and it only performs a bootup sorting Also fixed: - issue in FileSystem class where getting the file list recursively was using the wrong variable so sub-dirs would get messed up - deleted rubbish test code in main.cpp of ProcessMetrics --- .github/workflows/GUCEF_exe_FileSorter.yml | 53 ++ README.md | 1 + platform/gucefCORE/include/gucefCORE_CDate.h | 2 + .../gucefCORE/include/gucefCORE_CDateTime.h | 4 + platform/gucefCORE/include/gucefCORE_CIDate.h | 7 + .../include/gucefCORE_CResourceMetaData.h | 3 + platform/gucefCORE/src/gucefCORE_CDate.cpp | 14 + .../gucefCORE/src/gucefCORE_CDateTime.cpp | 36 + .../src/gucefCORE_CResourceMetaData.cpp | 71 ++ .../src/gucefVFS_CFileSystemArchive.cpp | 6 +- premake4.lua | 1 + projects/Android/targets/GUCEF/Android.mk | 3 + .../targets/GUCEF_exe_FileSorter/Android.mk | 131 ++++ .../targets/GUCEF_tag_services/Android.mk | 3 + .../all/GUCEF_exe_FileSorter/globpaths.txt | 26 + .../linux32/GUCEF_tag_services/globpaths.txt | 1 + .../linux64/GUCEF_tag_services/globpaths.txt | 1 + ...unCMake_Shared_VS2022_Win64_FileSorter.bat | 9 + .../targets/GUCEF/GUCEF_ModuleDirs.cmake | 1 + .../GUCEF_exe_FileSorter/CMakeLists.txt | 212 ++++++ .../GUCEF_exe_FileSorter_ModuleDirs.cmake | 47 ++ .../GUCEF_exe_FileSorter_Packaging.cmake | 163 +++++ .../GUCEF_tag_services_ModuleDirs.cmake | 5 + projects/premake5/targets/GUCEF/premake5.lua | 1 + .../targets/GUCEF_exe_FileSorter/premake5.lua | 60 ++ .../targets/GUCEF_tag_services/premake5.lua | 5 + tools/FileSorter/Android.mk | 48 ++ tools/FileSorter/CMakeLists.txt | 90 +++ tools/FileSorter/FileSorter.ini | 185 +++++ tools/FileSorter/FileSorter_d.ini | 185 +++++ tools/FileSorter/ModuleInfo.xml | 30 + tools/FileSorter/include/FileSorter.h | 281 ++++++++ tools/FileSorter/premake4.lua | 74 ++ tools/FileSorter/premake5.lua | 74 ++ tools/FileSorter/src/FileSorter.cpp | 656 ++++++++++++++++++ tools/FileSorter/src/main.cpp | 331 +++++++++ tools/ProcessMetrics/src/main.cpp | 41 -- 37 files changed, 2816 insertions(+), 45 deletions(-) create mode 100644 .github/workflows/GUCEF_exe_FileSorter.yml create mode 100644 projects/Android/targets/GUCEF_exe_FileSorter/Android.mk create mode 100644 projects/CI/targets/all/GUCEF_exe_FileSorter/globpaths.txt create mode 100644 projects/CMake/RunCMake_Shared_VS2022_Win64_FileSorter.bat create mode 100644 projects/CMake/targets/GUCEF_exe_FileSorter/CMakeLists.txt create mode 100644 projects/CMake/targets/GUCEF_exe_FileSorter/GUCEF_exe_FileSorter_ModuleDirs.cmake create mode 100644 projects/CMake/targets/GUCEF_exe_FileSorter/GUCEF_exe_FileSorter_Packaging.cmake create mode 100644 projects/premake5/targets/GUCEF_exe_FileSorter/premake5.lua create mode 100644 tools/FileSorter/Android.mk create mode 100644 tools/FileSorter/CMakeLists.txt create mode 100644 tools/FileSorter/FileSorter.ini create mode 100644 tools/FileSorter/FileSorter_d.ini create mode 100644 tools/FileSorter/ModuleInfo.xml create mode 100644 tools/FileSorter/include/FileSorter.h create mode 100644 tools/FileSorter/premake4.lua create mode 100644 tools/FileSorter/premake5.lua create mode 100644 tools/FileSorter/src/FileSorter.cpp create mode 100644 tools/FileSorter/src/main.cpp diff --git a/.github/workflows/GUCEF_exe_FileSorter.yml b/.github/workflows/GUCEF_exe_FileSorter.yml new file mode 100644 index 000000000..1ef4fcadf --- /dev/null +++ b/.github/workflows/GUCEF_exe_FileSorter.yml @@ -0,0 +1,53 @@ +name: target_GUCEF_exe_FileSorter + +on: + workflow_dispatch: + inputs: + archiveBuildArtifacts: + description: 'Archive Build Artifacts?' + required: false + default: 'false' + targetPlatform: + description: 'Target platform to build?' + required: false + default: 'all' + +jobs: + + GUCEF_exe_FileSorter-all: + runs-on: self-hosted + env: + TARGET_NAME: GUCEF_exe_FileSorter + TARGET_PLATFORM: all + TARGET_PROJECT: projects/CMake/targets/GUCEF_exe_FileSorter + PRODUCT_NAME: FileSorter + CI_TOOL: GITHUB-ACTIONS + BUILD_TOOL: CMAKE + steps: + - uses: actions/checkout@master + - name: Build FileSorter for platform all + run: ./projects/CI/targets/ci_build.sh + - name: Archive Debian build artifacts + uses: actions/upload-artifact@v2 + with: + name: Debian packages + path: | + ./common/bin/GUCEF_exe_FileSorter-all/packages/*FileSorter*.deb + - name: Archive RPM build artifacts + uses: actions/upload-artifact@v2 + with: + name: RPM packages + path: | + ./common/bin/GUCEF_exe_FileSorter-all/packages/*FileSorter*.rpm + - name: Archive Tarball - bz2 compressed build artifacts + uses: actions/upload-artifact@v2 + with: + name: tar.bz2 packages + path: | + ./common/bin/GUCEF_exe_FileSorter-all/packages/*FileSorter*.tar.bz2 + - name: Archive Tarball - Xz compressed build artifacts + uses: actions/upload-artifact@v2 + with: + name: tar.xz packages + path: | + ./common/bin/GUCEF_exe_FileSorter-all/packages/*FileSorter*.tar.xz diff --git a/README.md b/README.md index 3544a4b97..f718f72b9 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ If you get into trouble for whatever reason with stale/bad output files (disk is - pubsub2storage: Adapter service which translates more generally between messaging paradigms and storage. Will be superseded by pubsub2pubsub. - pubsub2pubsub: Adapter service which translates more generally between different messaging paradigms. Will supersede many of the other adapter services. - FilePusher: Agent service which monitors the file system for certain files and pushes them to a VFS destination for example AWS S3. +- FileSorter: Agent service which automatically sorts files. Handy for initial sort for digital picture and video archive for example. - GucefLogService: Service which can accept GUCEF platform logs streamed via network connection. Aimed at situations where we cannot have/access local logs - ServerPortExtender: Service used to reverse inbound/outbound connection initiation for an application server port thus bypassing egress only restrictions - UdpTransformer: Service which takes ingress UDP and performs a simplistic transform followed by a retransmission diff --git a/platform/gucefCORE/include/gucefCORE_CDate.h b/platform/gucefCORE/include/gucefCORE_CDate.h index 96da1e0aa..9430a8ca9 100644 --- a/platform/gucefCORE/include/gucefCORE_CDate.h +++ b/platform/gucefCORE/include/gucefCORE_CDate.h @@ -74,6 +74,8 @@ class GUCEF_CORE_PUBLIC_CPP CDate : public CIDate virtual UInt8 GetMonth( void ) const GUCEF_VIRTUAL_OVERRIDE; + virtual CORE::CString GetMonthName( void ) const GUCEF_VIRTUAL_OVERRIDE; + bool SetDay( UInt8 day ); virtual UInt8 GetDay( void ) const GUCEF_VIRTUAL_OVERRIDE; diff --git a/platform/gucefCORE/include/gucefCORE_CDateTime.h b/platform/gucefCORE/include/gucefCORE_CDateTime.h index 76ce8cbfc..977553bd1 100644 --- a/platform/gucefCORE/include/gucefCORE_CDateTime.h +++ b/platform/gucefCORE/include/gucefCORE_CDateTime.h @@ -150,6 +150,10 @@ class GUCEF_CORE_PUBLIC_CPP CDateTime : public CDate , void Clear( void ); + void AddSeconds( Int32 secondsToAdd ); + void AddMinutes( Int32 minutesToAdd ); + void AddHours( Int32 hoursToAdd ); + explicit CDateTime( const struct tm* src, bool isUtc ); explicit CDateTime( const time_t src, bool isUtc ); diff --git a/platform/gucefCORE/include/gucefCORE_CIDate.h b/platform/gucefCORE/include/gucefCORE_CIDate.h index 7071ee2e4..3f83754fd 100644 --- a/platform/gucefCORE/include/gucefCORE_CIDate.h +++ b/platform/gucefCORE/include/gucefCORE_CIDate.h @@ -31,6 +31,11 @@ #define GUCEF_CORE_MACROS_H #endif /* GUCEF_CORE_MACROS_H ? */ +#ifndef GUCEF_CORE_CSTRING_H +#include "gucefCORE_CString.h" +#define GUCEF_CORE_CSTRING_H +#endif /* GUCEF_CORE_CSTRING_H ? */ + /*-------------------------------------------------------------------------// // // // NAMESPACE // @@ -54,6 +59,8 @@ class GUCEF_CORE_PUBLIC_CPP CIDate virtual UInt8 GetMonth( void ) const = 0; + virtual CORE::CString GetMonthName( void ) const = 0; + virtual UInt8 GetDay( void ) const = 0; }; diff --git a/platform/gucefCORE/include/gucefCORE_CResourceMetaData.h b/platform/gucefCORE/include/gucefCORE_CResourceMetaData.h index 8b0b00b92..cef51722e 100644 --- a/platform/gucefCORE/include/gucefCORE_CResourceMetaData.h +++ b/platform/gucefCORE/include/gucefCORE_CResourceMetaData.h @@ -81,7 +81,10 @@ class GUCEF_CORE_PUBLIC_CPP CResourceMetaData CResourceMetaData( void ); CResourceMetaData( const CResourceMetaData& src ); + void Clear( void ); + + bool GetEarliestUtcDt( CORE::CDateTime& earliest ) const; }; /*-------------------------------------------------------------------------// diff --git a/platform/gucefCORE/src/gucefCORE_CDate.cpp b/platform/gucefCORE/src/gucefCORE_CDate.cpp index 163370624..d9da99ab4 100644 --- a/platform/gucefCORE/src/gucefCORE_CDate.cpp +++ b/platform/gucefCORE/src/gucefCORE_CDate.cpp @@ -226,6 +226,20 @@ CDate::GetMonth( void ) const /*-------------------------------------------------------------------------*/ +CORE::CString +CDate::GetMonthName( void ) const +{GUCEF_TRACE; + + static const char* monthNames[] = { "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" }; + if ( m_month >= 1 && m_month <= 12 ) + return monthNames[ m_month-1 ]; + else + return "Unknown"; +} + +/*-------------------------------------------------------------------------*/ + bool CDate::SetDay( UInt8 day ) {GUCEF_TRACE; diff --git a/platform/gucefCORE/src/gucefCORE_CDateTime.cpp b/platform/gucefCORE/src/gucefCORE_CDateTime.cpp index 2beb101fc..06c3fb2c6 100644 --- a/platform/gucefCORE/src/gucefCORE_CDateTime.cpp +++ b/platform/gucefCORE/src/gucefCORE_CDateTime.cpp @@ -1290,6 +1290,42 @@ CDateTime::Clear( void ) *this = Empty; } +/*-------------------------------------------------------------------------*/ + +void +CDateTime::AddSeconds( Int32 secondsToAdd ) +{GUCEF_TRACE; + + UInt64 baseTimestamp = ToUnixEpochBasedTicksInMillisecs(); + Int64 msDelta = (Int64) secondsToAdd * 1000; + baseTimestamp += msDelta; + FromUnixEpochBasedTicksInMillisecs( baseTimestamp ); +} + +/*-------------------------------------------------------------------------*/ + +void +CDateTime::AddMinutes( Int32 minutesToAdd ) +{GUCEF_TRACE; + + UInt64 baseTimestamp = ToUnixEpochBasedTicksInMillisecs(); + Int64 msDelta = (Int64) minutesToAdd * 60 * 1000; + baseTimestamp += msDelta; + FromUnixEpochBasedTicksInMillisecs( baseTimestamp ); +} + +/*-------------------------------------------------------------------------*/ + +void +CDateTime::AddHours( Int32 hoursToAdd ) +{GUCEF_TRACE; + + UInt64 baseTimestamp = ToUnixEpochBasedTicksInMillisecs(); + Int64 msDelta = (Int64) hoursToAdd * 60 * 60 * 1000; + baseTimestamp += msDelta; + FromUnixEpochBasedTicksInMillisecs( baseTimestamp ); +} + /*-------------------------------------------------------------------------// // // // NAMESPACE // diff --git a/platform/gucefCORE/src/gucefCORE_CResourceMetaData.cpp b/platform/gucefCORE/src/gucefCORE_CResourceMetaData.cpp index f4a49b373..35fab3968 100644 --- a/platform/gucefCORE/src/gucefCORE_CResourceMetaData.cpp +++ b/platform/gucefCORE/src/gucefCORE_CResourceMetaData.cpp @@ -99,6 +99,77 @@ CResourceMetaData::Clear( void ) resourceExists = false; } +/*-------------------------------------------------------------------------*/ + +bool +CResourceMetaData::GetEarliestUtcDt( CORE::CDateTime& earliest ) const +{GUCEF_TRACE; + + if ( hasCreationDateTime && hasModifiedDateTime && hasLastAccessedDateTime ) + { + if ( creationDateTime > modifiedDateTime ) + { + if ( modifiedDateTime > lastAccessedDateTime ) + { + earliest = lastAccessedDateTime.ToUTC(); + return true; + } + else + { + earliest = modifiedDateTime.ToUTC(); + return true; + } + } + else + { + if ( creationDateTime > lastAccessedDateTime ) + { + earliest = lastAccessedDateTime.ToUTC(); + return true; + } + else + { + earliest = creationDateTime.ToUTC(); + return true; + } + } + } + else + if ( hasCreationDateTime && hasModifiedDateTime ) + { + if ( creationDateTime > modifiedDateTime ) + { + earliest = modifiedDateTime.ToUTC(); + return true; + } + else + { + earliest = creationDateTime.ToUTC(); + return true; + } + } + else + if ( hasCreationDateTime ) + { + earliest = creationDateTime.ToUTC(); + return true; + } + else + if ( hasModifiedDateTime ) + { + earliest = modifiedDateTime.ToUTC(); + return true; + } + else + if ( hasLastAccessedDateTime ) + { + earliest = lastAccessedDateTime.ToUTC(); + return true; + } + + return false; +} + /*-------------------------------------------------------------------------// // // // NAMESPACE // diff --git a/platform/gucefVFS/src/gucefVFS_CFileSystemArchive.cpp b/platform/gucefVFS/src/gucefVFS_CFileSystemArchive.cpp index d263d8cfe..8fe03128c 100644 --- a/platform/gucefVFS/src/gucefVFS_CFileSystemArchive.cpp +++ b/platform/gucefVFS/src/gucefVFS_CFileSystemArchive.cpp @@ -268,7 +268,6 @@ CFileSystemArchive::GetListFromRoot( const CORE::CString& actualFsDir , CORE::CString vfsPath = CORE::CombinePath( vfsMountLocation, vfsArchiveLocation ); - CORE::CString filename; struct CORE::SDI_Data* did = CORE::DI_First_Dir_Entry( actualFsDir.C_String() ); if ( did != NULL ) { @@ -282,7 +281,7 @@ CFileSystemArchive::GetListFromRoot( const CORE::CString& actualFsDir , { if ( addFiles ) { - filename = CORE::DI_Name( did ); + CORE::CString filename = CORE::DI_Name( did ); if ( filename != '.' && filename != ".." ) { if ( CVFS::FilterValidation( filename , @@ -318,9 +317,8 @@ CFileSystemArchive::GetListFromRoot( const CORE::CString& actualFsDir , if ( recursive ) { - CORE::CString fsSubdir = CORE::CombinePath( actualFsDir, dirName ); - CORE::CString vfsSubdir = CORE::CombinePath( vfsArchiveLocation, filename ); + CORE::CString vfsSubdir = CORE::CombinePath( vfsArchiveLocation, dirName ); // Recursively process the sub-dir GetListFromRoot( fsSubdir , diff --git a/premake4.lua b/premake4.lua index 05acc3b54..1bc7f4420 100644 --- a/premake4.lua +++ b/premake4.lua @@ -185,6 +185,7 @@ solution( "GUCEF" ) include( "tools/FileDiff" ) include( "tools/FilePusher" ) include( "tools/FileReplacer" ) + include( "tools/FileSorter" ) include( "tools/GucefArchiver" ) include( "tools/GucefLogServiceApp" ) include( "tools/GucefLogServiceClientPlugin" ) diff --git a/projects/Android/targets/GUCEF/Android.mk b/projects/Android/targets/GUCEF/Android.mk index 833b2cd88..b2f4ebf4e 100644 --- a/projects/Android/targets/GUCEF/Android.mk +++ b/projects/Android/targets/GUCEF/Android.mk @@ -411,6 +411,9 @@ include $(MY_MODULE_PATH)/Android.mk MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../tools/FilePusher include $(MY_MODULE_PATH)/Android.mk +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../tools/FileSorter +include $(MY_MODULE_PATH)/Android.mk + MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../tools/ProcessMetrics include $(MY_MODULE_PATH)/Android.mk diff --git a/projects/Android/targets/GUCEF_exe_FileSorter/Android.mk b/projects/Android/targets/GUCEF_exe_FileSorter/Android.mk new file mode 100644 index 000000000..5ed3f2e83 --- /dev/null +++ b/projects/Android/targets/GUCEF_exe_FileSorter/Android.mk @@ -0,0 +1,131 @@ +#------------------------------------------------------------------- +# This file has been automatically generated by ProjectGenerator +# which is part of a build system designed for GUCEF +# (Galaxy Unlimited Framework) +# For the latest info, see http://www.VanvelzenSoftware.com/ +# +# The contents of this file are placed in the public domain. Feel +# free to make use of it in any way you like. +#------------------------------------------------------------------- + + +# +# This is the project makefile which includes all modules which are part of this project +# +# PROJECT: "GUCEF_exe_FileSorter" +# + +ifndef PROJECT_ROOT_PATH + PROJECT_ROOT_PATH := $(call my-dir) +endif + +include $(CLEAR_VARS) + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/curl +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/json-parser +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/libparsifal +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/libyaml +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/stbrumme-hash-library +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/zziplib +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/aws-crt-cpp/crt/aws-c-common +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/json-builder +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../platform/gucefCORE +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../platform/gucefMT +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../platform/gucefCOMCORE +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/aws-crt-cpp/crt/aws-c-cal +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/aws-crt-cpp/crt/aws-c-compression +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/aws-crt-cpp/crt/aws-c-sdkutils +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/aws-crt-cpp/crt/aws-checksums +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../platform/gucefCOM +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../platform/gucefVFS +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../plugins/CORE/codecspluginSTBRUMMEHASH +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../plugins/CORE/codecspluginZLIB +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../plugins/CORE/dstorepluginPARSIFALXML +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../plugins/CORE/dstorepluginYAML +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../plugins/VFS/vfspluginZIP +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/aws-crt-cpp/crt/aws-c-io +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../platform/gucefWEB +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../plugins/CORE/dstorepluginJSONPARSER +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../tools/FileSorter +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/aws-crt-cpp/crt/aws-c-http +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/aws-crt-cpp/crt/aws-c-mqtt +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/aws-crt-cpp/crt/aws-c-auth +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/aws-crt-cpp/crt/aws-c-event-stream +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/aws-crt-cpp/crt/aws-c-s3 +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/aws-crt-cpp +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/aws-cpp-sdk-core +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../plugins/SHARED/pluginglueAWSSDK +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../dependencies/aws-cpp-sdk-s3 +include $(MY_MODULE_PATH)/Android.mk + +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../plugins/VFS/vfspluginAWSS3 +include $(MY_MODULE_PATH)/Android.mk + diff --git a/projects/Android/targets/GUCEF_tag_services/Android.mk b/projects/Android/targets/GUCEF_tag_services/Android.mk index b48fdaddf..21770aee6 100644 --- a/projects/Android/targets/GUCEF_tag_services/Android.mk +++ b/projects/Android/targets/GUCEF_tag_services/Android.mk @@ -150,6 +150,9 @@ include $(MY_MODULE_PATH)/Android.mk MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../tools/FilePusher include $(MY_MODULE_PATH)/Android.mk +MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../tools/FileSorter +include $(MY_MODULE_PATH)/Android.mk + MY_MODULE_PATH := $(PROJECT_ROOT_PATH)/../../../../tools/ProcessMetrics include $(MY_MODULE_PATH)/Android.mk diff --git a/projects/CI/targets/all/GUCEF_exe_FileSorter/globpaths.txt b/projects/CI/targets/all/GUCEF_exe_FileSorter/globpaths.txt new file mode 100644 index 000000000..acfec76b9 --- /dev/null +++ b/projects/CI/targets/all/GUCEF_exe_FileSorter/globpaths.txt @@ -0,0 +1,26 @@ +common/include/* +dependencies/aws-cpp-sdk-core/* +dependencies/aws-cpp-sdk-s3/* +dependencies/aws-crt-cpp/* +dependencies/curl/* +dependencies/json-builder/* +dependencies/json-parser/* +dependencies/libparsifal/* +dependencies/libyaml/* +dependencies/stbrumme-hash-library/* +dependencies/zlib/* +dependencies/zziplib/* +platform/gucefCOM/* +platform/gucefCORE/* +platform/gucefMT/* +platform/gucefVFS/* +platform/gucefWEB/* +plugins/CORE/codecspluginSTBRUMMEHASH/* +plugins/CORE/codecspluginZLIB/* +plugins/CORE/dstorepluginJSONPARSER/* +plugins/CORE/dstorepluginPARSIFALXML/* +plugins/CORE/dstorepluginYAML/* +plugins/SHARED/pluginglueAWSSDK/* +plugins/VFS/vfspluginAWSS3/* +plugins/VFS/vfspluginZIP/* +tools/FileSorter/* diff --git a/projects/CI/targets/linux32/GUCEF_tag_services/globpaths.txt b/projects/CI/targets/linux32/GUCEF_tag_services/globpaths.txt index 142ccd4c7..d6f409000 100644 --- a/projects/CI/targets/linux32/GUCEF_tag_services/globpaths.txt +++ b/projects/CI/targets/linux32/GUCEF_tag_services/globpaths.txt @@ -14,6 +14,7 @@ plugins/SHARED/pluginglueAWSSDK/* plugins/VFS/vfspluginAWSS3/* plugins/VFS/vfspluginZIP/* tools/FilePusher/* +tools/FileSorter/* tools/GucefLogServiceApp/* tools/GucefLogServiceClientPlugin/* tools/GucefLogServiceLib/* diff --git a/projects/CI/targets/linux64/GUCEF_tag_services/globpaths.txt b/projects/CI/targets/linux64/GUCEF_tag_services/globpaths.txt index 142ccd4c7..d6f409000 100644 --- a/projects/CI/targets/linux64/GUCEF_tag_services/globpaths.txt +++ b/projects/CI/targets/linux64/GUCEF_tag_services/globpaths.txt @@ -14,6 +14,7 @@ plugins/SHARED/pluginglueAWSSDK/* plugins/VFS/vfspluginAWSS3/* plugins/VFS/vfspluginZIP/* tools/FilePusher/* +tools/FileSorter/* tools/GucefLogServiceApp/* tools/GucefLogServiceClientPlugin/* tools/GucefLogServiceLib/* diff --git a/projects/CMake/RunCMake_Shared_VS2022_Win64_FileSorter.bat b/projects/CMake/RunCMake_Shared_VS2022_Win64_FileSorter.bat new file mode 100644 index 000000000..3704a0970 --- /dev/null +++ b/projects/CMake/RunCMake_Shared_VS2022_Win64_FileSorter.bat @@ -0,0 +1,9 @@ +CALL CMakeCommon.bat + +ECHO *** Set VS2022 specifics and run CMake *** + +SET MAINCMAKE=%SRCROOTDIR%\projects\CMake\targets\GUCEF_exe_FileSorter +SET VS22_OUTPUTDIR="%OUTPUTDIR%\VS2022_x64_FileSorter" + +CMake.exe -DBUILD_SHARED_LIBS=ON -G"Visual Studio 17 2022" -A x64 -H"%MAINCMAKE%" -B%VS22_OUTPUTDIR% +PAUSE \ No newline at end of file diff --git a/projects/CMake/targets/GUCEF/GUCEF_ModuleDirs.cmake b/projects/CMake/targets/GUCEF/GUCEF_ModuleDirs.cmake index 32a00d1f6..284e9f5f5 100644 --- a/projects/CMake/targets/GUCEF/GUCEF_ModuleDirs.cmake +++ b/projects/CMake/targets/GUCEF/GUCEF_ModuleDirs.cmake @@ -174,6 +174,7 @@ add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/DuplicateFileFin add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/FileDiff ${CMAKE_BINARY_DIR}/FileDiff ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/FilePusher ${CMAKE_BINARY_DIR}/FilePusher ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/FileReplacer ${CMAKE_BINARY_DIR}/FileReplacer ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/FileSorter ${CMAKE_BINARY_DIR}/FileSorter ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/GucefArchiver ${CMAKE_BINARY_DIR}/GucefArchiver ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/GucefLogServiceApp ${CMAKE_BINARY_DIR}/GucefLogServiceApp ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/GucefLogServiceClientPlugin ${CMAKE_BINARY_DIR}/GucefLogServiceClientPlugin ) diff --git a/projects/CMake/targets/GUCEF_exe_FileSorter/CMakeLists.txt b/projects/CMake/targets/GUCEF_exe_FileSorter/CMakeLists.txt new file mode 100644 index 000000000..31ad45e34 --- /dev/null +++ b/projects/CMake/targets/GUCEF_exe_FileSorter/CMakeLists.txt @@ -0,0 +1,212 @@ +#------------------------------------------------------------------- +# This file is part of the CMake build system for GUCEF +# (Galaxy Unlimited Framework) +# For the latest info, see http://www.VanvelzenSoftware.com/ +# +# The contents of this file are placed in the public domain. Feel +# free to make use of it in any way you like. +#------------------------------------------------------------------- + +###################################################################### +# GUCEF_exe_FileSorter BUILD SYSTEM +# Welcome to the CMake build system for GUCEF_exe_FileSorter. +# This is the main file where we prepare the general build environment +# and provide build configuration options. +###################################################################### + +cmake_minimum_required(VERSION 2.6) +set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE) +cmake_policy(SET CMP0003 NEW) + +if ( DEFINED ENV{GUCEF_HOME} ) + set( GUCEF_HOME_DIR "$ENV{GUCEF_HOME}" ) + STRING(REGEX REPLACE "\\\\" "/" GUCEF_HOME_DIR ${GUCEF_HOME_DIR}) + message(STATUS "Setting CMake variable GUCEF_HOME_DIR based on env var GUCEF_HOME to ${GUCEF_HOME_DIR}") +endif() +if ( DEFINED ENV{GUCEF_SOURCE_DIR} ) + set( GUCEF_SOURCE_DIR "$ENV{GUCEF_SOURCE_DIR}" ) + STRING(REGEX REPLACE "\\\\" "/" GUCEF_SOURCE_DIR ${GUCEF_SOURCE_DIR}) + message(STATUS "Setting CMake variable GUCEF_SOURCE_DIR based on env var GUCEF_SOURCE_DIR to ${GUCEF_SOURCE_DIR}") +endif() + +if ( NOT DEFINED GUCEF_HOME_DIR ) + set( GUCEF_HOME_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../" ) + message(STATUS "GUCEF_HOME_DIR not defined, defaulting to CMake file relative dir: ${GUCEF_HOME_DIR}") +endif() +if ( NOT DEFINED GUCEF_SOURCE_DIR ) + set( GUCEF_SOURCE_DIR ${GUCEF_HOME_DIR} ) + message(STATUS "GUCEF_SOURCE_DIR not defined, defaulting to GUCEF_HOME_DIR: ${GUCEF_HOME_DIR}") +endif() +if ( NOT DEFINED GUCEF_BINARY_DIR ) + set( GUCEF_BINARY_DIR "${CMAKE_BINARY_DIR}" ) +endif() + +set( CMAKE_INSTALL_PREFIX "${GUCEF_BINARY_DIR}/dist" CACHE PATH + "Install path prefix, prepended onto install directories." FORCE ) + +message(STATUS "Source dir: ${GUCEF_SOURCE_DIR}") +message(STATUS "Binary dir: ${GUCEF_BINARY_DIR}") +message(STATUS "CMake Binary dir: ${CMAKE_BINARY_DIR}") + +if ( NOT DEFINED GUCEF_SYSTEM_NAME ) + if ( DEFINED CMAKE_SYSTEM_NAME ) + set( GUCEF_SYSTEM_NAME ${CMAKE_SYSTEM_NAME} ) + else() + set( GUCEF_SYSTEM_NAME ${CMAKE_HOST_SYSTEM_NAME} ) + endif() +endif() + +if ( GUCEF_SYSTEM_NAME STREQUAL "Linux" ) + if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) + set( LINUX64 TRUE ) + set( GUCEF_TARGET_PLATFORM "LINUX64" ) + else () + set( LINUX32 TRUE ) + set( GUCEF_TARGET_PLATFORM "LINUX32" ) + endif() +endif() + +message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}" ) +message(STATUS "GUCEF_TARGET_PLATFORM: ${GUCEF_TARGET_PLATFORM}" ) + + +project( GUCEF_exe_FileSorter ) + +# Include necessary submodules +set(CMAKE_MODULE_PATH + "${GUCEF_SOURCE_DIR}/projects/CMake" + "${GUCEF_SOURCE_DIR}/projects/CMake/Utils" + "${GUCEF_SOURCE_DIR}/projects/CMake/Packages" +) +include(CMakeDependentOption) +include(MacroLogFeature) +include(GUCEFConfigTargets) +include(PreprocessorUtils) +set(GUCEF_TEMPLATES_DIR "${GUCEF_SOURCE_DIR}/projects/CMake/Templates") +set(GUCEF_WORK_DIR ${GUCEF_BINARY_DIR}) + + +##################################################################### +# Set up the basic build environment +##################################################################### + +if (CMAKE_BUILD_TYPE STREQUAL "") + # CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up + # differentiation between debug and release builds. + set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE) +endif () + +# determine GUCEF_exe_FileSorter version numbers +include(GUCEFGetVersion) +GUCEF_get_version(${GUCEF_SOURCE_DIR}/common/include/gucef_prerequisites.h) +message(STATUS "Configuring GUCEF_exe_FileSorter ${GUCEF_VERSION}") + +if (NOT APPLE) + # Create debug libraries with _d postfix + set(CMAKE_DEBUG_POSTFIX "_d") +endif () + +# Set compiler specific build flags +if (CMAKE_COMPILER_IS_GNUCXX) + add_definitions(-msse) +endif () +if (MSVC) + add_definitions(/fp:fast) +endif () + +if (CMAKE_COMPILER_IS_GNUCXX) + # Test for GCC visibility + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag(-fvisibility=hidden GUCEF_GCC_VISIBILITY) + if (GUCEF_GCC_VISIBILITY) + # determine gcc version + execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion + OUTPUT_VARIABLE GUCEF_GCC_VERSION) + message(STATUS "Detected g++ ${GUCEF_GCC_VERSION}") + message(STATUS "Enabling GCC visibility flags") + set(GUCEF_GCC_VISIBILITY_FLAGS "-DGUCEF_GCC_VISIBILITY -fvisibility=hidden") + + # check if we can safely add -fvisibility-inlines-hidden + string(TOLOWER "${CMAKE_BUILD_TYPE}" GUCEF_BUILD_TYPE) + if (GUCEF_BUILD_TYPE STREQUAL "debug" AND GUCEF_GCC_VERSION VERSION_LESS "4.2") + message(STATUS "Skipping -fvisibility-inlines-hidden due to possible bug in g++ < 4.2") + else () + set(GUCEF_GCC_VISIBILITY_FLAGS "${GUCEF_GCC_VISIBILITY_FLAGS} -fvisibility-inlines-hidden") + endif () + endif (GUCEF_GCC_VISIBILITY) +endif (CMAKE_COMPILER_IS_GNUCXX) + +# determine system endianess +include(TestBigEndian) +test_big_endian(GUCEF_TEST_BIG_ENDIAN) + +# Add common include path +include_directories("${GUCEF_SOURCE_DIR}/common/include") + +# Specify build paths +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${GUCEF_BINARY_DIR}/lib") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${GUCEF_BINARY_DIR}/lib") +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${GUCEF_BINARY_DIR}/bin") + +# Set up iPhone overrides. +if (GUCEF_BUILD_PLATFORM_IPHONE) + # Force gcc <= 4.2 on iPhone + include(CMakeForceCompiler) + CMAKE_FORCE_C_COMPILER(gcc-4.2 GNU) + CMAKE_FORCE_CXX_COMPILER(gcc-4.2 GNU) + + # Set build variables + set(CMAKE_OSX_SYSROOT iphoneos3.0) + set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_UNIVERSAL_IPHONE_OS)") + set(CMAKE_EXE_LINKER_FLAGS "-framework Foundation -framework CoreGraphics -framework QuartzCore -framework UIKit ${GUCEF_SOURCE_DIR}/iPhoneDependencies/lib/release/libboost_date_time.a ${GUCEF_SOURCE_DIR}/iPhoneDependencies/lib/release/libboost_thread.a") + set(XCODE_ATTRIBUTE_SDKROOT iphoneos3.0) + set(GUCEF_BUILD_RENDERSYSTEM_GLES TRUE CACHE BOOL "Forcing OpenGL ES RenderSystem for iPhone" FORCE) + set(GUCEF_STATIC TRUE CACHE BOOL "Forcing static build for iPhone" FORCE) + set(GUCEF_SET_USE_BOOST TRUE CACHE BOOL "Forcing use of Boost libraries for iPhone" FORCE) + set(GUCEF_USE_BOOST TRUE CACHE BOOL "Forcing use of Boost libraries for iPhone" FORCE) + set(Boost_FOUND TRUE CACHE BOOL "Forcing use of Boost libraries for iPhone" FORCE) + set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.yourcompany.\${PRODUCT_NAME:rfc1034identifier}") + + add_definitions(-fno-regmove) + remove_definitions(-msse) +elseif (APPLE AND NOT GUCEF_BUILD_PLATFORM_IPHONE) + # Force gcc <= 4.0 on Mac OS X because 4.2 is not supported prior to Mac OS X 10.5 + include(CMakeForceCompiler) + CMAKE_FORCE_C_COMPILER(gcc-4.0 GNU) + CMAKE_FORCE_CXX_COMPILER(gcc-4.0 GNU) + + # Set 10.4 as the base SDK by default + set(XCODE_ATTRIBUTE_SDKROOT macosx10.4) + +endif () + +###################################################################### +# Provide user options to customise the build process +###################################################################### + +# Customise what to build +option(GUCEF_STATIC "Static build" FALSE) +set(GUCEF_CONFIG_ALLOCATOR 2 CACHE STRING +"Specify the memory allocator to use. Possible values: + 1 - Standard allocator + 2 - nedmalloc + 3 - User-provided allocator" +) +option(GUCEF_CONFIG_MEMTRACK_DEBUG "Enable GUCEF's memory tracker in debug mode" FALSE) +option(GUCEF_CONFIG_MEMTRACK_RELEASE "Enable GUCEF's memory tracker in release mode" FALSE) + + +################################################################### +# configure global build settings based on selected build options +################################################################### + +include(ConfigureBuild) + +################################################################## +# Now setup targets +################################################################## + +include( GUCEF_exe_FileSorter_ModuleDirs.cmake ) + +# Provide CPack packaging target +include( GUCEF_exe_FileSorter_Packaging.cmake ) diff --git a/projects/CMake/targets/GUCEF_exe_FileSorter/GUCEF_exe_FileSorter_ModuleDirs.cmake b/projects/CMake/targets/GUCEF_exe_FileSorter/GUCEF_exe_FileSorter_ModuleDirs.cmake new file mode 100644 index 000000000..eac271f4e --- /dev/null +++ b/projects/CMake/targets/GUCEF_exe_FileSorter/GUCEF_exe_FileSorter_ModuleDirs.cmake @@ -0,0 +1,47 @@ +#------------------------------------------------------------------- +# This file was automatically generated by ProjectGenerator +# which is tooling part the build system designed for GUCEF +# (Galaxy Unlimited Framework) +# For the latest info, see http://www.VanvelzenSoftware.com/ +# +# The contents of this file are placed in the public domain. Feel +# free to make use of it in any way you like. +#------------------------------------------------------------------- +# +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/aws-cpp-sdk-core ${CMAKE_BINARY_DIR}/aws-cpp-sdk-core ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/aws-cpp-sdk-s3 ${CMAKE_BINARY_DIR}/aws-cpp-sdk-s3 ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/aws-crt-cpp ${CMAKE_BINARY_DIR}/aws-crt-cpp ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/aws-crt-cpp/crt/aws-c-auth ${CMAKE_BINARY_DIR}/aws-c-auth ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/aws-crt-cpp/crt/aws-c-cal ${CMAKE_BINARY_DIR}/aws-c-cal ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/aws-crt-cpp/crt/aws-c-common ${CMAKE_BINARY_DIR}/aws-c-common ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/aws-crt-cpp/crt/aws-c-compression ${CMAKE_BINARY_DIR}/aws-c-compression ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/aws-crt-cpp/crt/aws-c-event-stream ${CMAKE_BINARY_DIR}/aws-c-event-stream ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/aws-crt-cpp/crt/aws-c-http ${CMAKE_BINARY_DIR}/aws-c-http ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/aws-crt-cpp/crt/aws-c-io ${CMAKE_BINARY_DIR}/aws-c-io ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/aws-crt-cpp/crt/aws-c-mqtt ${CMAKE_BINARY_DIR}/aws-c-mqtt ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/aws-crt-cpp/crt/aws-c-s3 ${CMAKE_BINARY_DIR}/aws-c-s3 ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/aws-crt-cpp/crt/aws-c-sdkutils ${CMAKE_BINARY_DIR}/aws-c-sdkutils ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/aws-crt-cpp/crt/aws-checksums ${CMAKE_BINARY_DIR}/aws-checksums ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/curl ${CMAKE_BINARY_DIR}/curl ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/json-builder ${CMAKE_BINARY_DIR}/jsonbuilder ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/json-parser ${CMAKE_BINARY_DIR}/jsonparser ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/libparsifal ${CMAKE_BINARY_DIR}/libparsifal ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/libyaml ${CMAKE_BINARY_DIR}/yaml ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/stbrumme-hash-library ${CMAKE_BINARY_DIR}/stbrumme-hash ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/zlib ${CMAKE_BINARY_DIR}/zlib ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../dependencies/zziplib ${CMAKE_BINARY_DIR}/zziplib ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../platform/gucefCOM ${CMAKE_BINARY_DIR}/gucefCOM ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../platform/gucefCOMCORE ${CMAKE_BINARY_DIR}/gucefCOMCORE ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../platform/gucefCORE ${CMAKE_BINARY_DIR}/gucefCORE ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../platform/gucefMT ${CMAKE_BINARY_DIR}/gucefMT ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../platform/gucefVFS ${CMAKE_BINARY_DIR}/gucefVFS ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../platform/gucefWEB ${CMAKE_BINARY_DIR}/gucefWEB ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/CORE/codecspluginSTBRUMMEHASH ${CMAKE_BINARY_DIR}/codecspluginSTBRUMMEHASH ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/CORE/codecspluginZLIB ${CMAKE_BINARY_DIR}/codecspluginZLIB ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/CORE/dstorepluginJSONPARSER ${CMAKE_BINARY_DIR}/dstorepluginJSONPARSER ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/CORE/dstorepluginPARSIFALXML ${CMAKE_BINARY_DIR}/dstorepluginPARSIFALXML ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/CORE/dstorepluginYAML ${CMAKE_BINARY_DIR}/dstorepluginYAML ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/SHARED/pluginglueAWSSDK ${CMAKE_BINARY_DIR}/pluginglueAWSSDK ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/VFS/vfspluginAWSS3 ${CMAKE_BINARY_DIR}/vfspluginAWSS3 ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/VFS/vfspluginZIP ${CMAKE_BINARY_DIR}/vfspluginZIP ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/FileSorter ${CMAKE_BINARY_DIR}/FileSorter ) diff --git a/projects/CMake/targets/GUCEF_exe_FileSorter/GUCEF_exe_FileSorter_Packaging.cmake b/projects/CMake/targets/GUCEF_exe_FileSorter/GUCEF_exe_FileSorter_Packaging.cmake new file mode 100644 index 000000000..54e082c31 --- /dev/null +++ b/projects/CMake/targets/GUCEF_exe_FileSorter/GUCEF_exe_FileSorter_Packaging.cmake @@ -0,0 +1,163 @@ + +#------------------------------------------------------------------------------ +# CPACK +include(InstallRequiredSystemLibraries) + +set(CPACK_MONOLITHIC_INSTALL 1) +set(CPACK_PACKAGE_VENDOR "Vanvelzen LLC") +set(CPACK_PACKAGE_NAME FileSorter ) +set(CPACK_PACKAGE_CONTACT "Dinand Vanvelzen ") +set(HOMEPAGE "https://github.com/LiberatorUSA/GUCEF") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "This is a description") +#set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/readme.md") +#set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/license.md") +set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) +set(CPACK_EXT_ENABLE_STAGING 1) + +set(CPACK_PACKAGE_INSTALL_DIRECTORY "FileSorter") +set(CPACK_PACKAGE_DIRECTORY "${GUCEF_BINARY_DIR}/packages") +set(CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION TRUE) +set(CPACK_PACKAGE_EXECUTABLES "GUCEF" "GUCEF") +set(CPACK_CREATE_DESKTOP_LINKS "GUCEF") +set(CPACK_STRIP_FILES FALSE ) + +if(WIN32 AND NOT UNIX) + #-------------------------------------------------------------------------- + # Windows specific + set(CPACK_GENERATOR "STGZ;ZIP;External") + message(STATUS "Package generation - Windows") + message(STATUS " + STGZ YES ") + message(STATUS " + ZIP YES ") + message(STATUS " + External YES ") + + # NSIS windows installer + find_program(NSIS_PATH nsis PATH_SUFFIXES nsis) + if(NSIS_PATH) + set(CPACK_GENERATOR "${CPACK_GENERATOR};NSIS") + message(STATUS " + NSIS YES ") + # Note: There is a bug in NSI that does not handle full unix paths properly. Make + # sure there is at least one set of four (4) backlasshes. + set(CPACK_NSIS_DISPLAY_NAME ${CPACK_PACKAGE_NAME}) + # Icon of the installer +# set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\exampleApp.ico") + # set(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.my-project-home-page.org") + # set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.my-personal-home-page.com") + set(CPACK_NSIS_CONTACT "${CPACK_PACKAGE_CONTACT}") + set(CPACK_NSIS_MODIFY_PATH ON) + else() + message(STATUS " + NSIS NO ") + endif() + +# set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\exampleApp.png") + + # Configure file with right path, place the result to PROJECT_BINARY_DIR. + # When ${PROJECT_BINARY_DIR}/exampleApp.icon.rc is added to an executable + # it will have icon specified in exampleApp.icon.in.rc +# configure_file(${CMAKE_CURRENT_SOURCE_DIR}/exampleApp.icon.in.rc +# ${PROJECT_BINARY_DIR}/exampleApp.icon.rc) + +elseif(APPLE) + #-------------------------------------------------------------------------- + # Apple specific + set(CPACK_GENERATOR "DragNDrop") + set(CPACK_PACKAGING_INSTALL_PREFIX "/") + + set(MACOSX_BUNDLE_BUNDLE_NAME ${CPACK_PACKAGE_NAME}) + set(MACOSX_BUNDLE_BUNDLE_GUI_IDENTIFIER "com.exampleApp.exampleApp") + set(MACOSX_BUNDLE_ICON_FILE ${PROJECT_SOURCE_DIR}/packaging/ exampleApp.icns) + set(MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/packaging/MacOSXBundleInfo.plist.in) + set(MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") + + set_source_files_properties(${PROJECT_SOURCE_DIR}/packaging/exampleApp.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") + + set(CPACK_DMG_VOLUME_NAME "exampleApp") + set(CPACK_DMG_DS_STORE_SETUP_SCRIPT "${PROJECT_SOURCE_DIR}/packaging/DS_Store.scpt") + set(CPACK_DMG_BACKGROUND_IMAGE "${PROJECT_SOURCE_DIR}/packaging/dmg_background.png") + set(CPACK_OSX_PACKAGE_VERSION "10.6") #min package version + +else() + #----------------------------------------------------------------------------- + # Linux specific + set(CPACK_GENERATOR "DEB;TBZ2;TXZ;External") + message(STATUS "Package generation - UNIX") + message(STATUS " + DEB YES ") + message(STATUS " + TBZ2 YES ") + message(STATUS " + TXZ YES ") + message(STATUS " + External YES ") + + find_program(RPMBUILD_PATH rpmbuild) + if(RPMBUILD_PATH) + message(STATUS " + RPM YES ") + set(CPACK_GENERATOR "${CPACK_GENERATOR};RPM") + set(CPACK_RPM_PACKAGE_LICENSE "MIT") + # set(CPACK_RPM_PACKAGE_REQUIRES "gtkmm30") + # exclude folders which clash with default ones + set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST + ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST} + /usr + /usr/bin + /usr/share + /usr/share/applications + /usr/share/doc + /usr/share/icons + /usr/share/icons/hicolor + /usr/share/icons/hicolor/256x256 + /usr/share/icons/hicolor/256x256/apps + /usr/share/icons/gnome + /usr/share/icons/gnome/256x256 + /usr/share/icons/gnome/256x256/apps) + else() + message(STATUS " + RPM NO ") + endif() + + IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE) + FIND_PROGRAM(DPKG_CMD dpkg) + IF(NOT DPKG_CMD) + MESSAGE(STATUS "Can not find dpkg in your path, default to amd64.") + SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64) + ENDIF(NOT DPKG_CMD) + EXECUTE_PROCESS(COMMAND "${DPKG_CMD}" --print-architecture + OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + ENDIF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE) + + set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE) + set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "${HOMEPAGE}") + set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Dinand Vanvelzen") + set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "DEB test description") + set(CPACK_DEBIAN_COMPRESSION_TYPE "gzip") + set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") + set(CPACK_DEBIAN_PACKAGE_SECTION "devel") + # set(CPACK_DEBIAN_PACKAGE_DEPENDS "libgtkmm-3.0") + + + + # Icon and app shortcut for Linux systems + # Note: .desktop file must have same name as executable +# install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/exampleApp.desktop +# DESTINATION share/applications/ +# PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ +# ) +# install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/exampleApp.png +# DESTINATION share/icons/hicolor/256x256/apps/ +# PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ +# ) +# install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/exampleApp.png +# DESTINATION share/icons/gnome/256x256/apps/ +# PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ +# ) + # License file +# install(FILES ${PROJECT_SOURCE_DIR}/license.md +# DESTINATION share/doc/${PROJECT_NAME}/ +# PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ +# RENAME copyright) + # set package icon +# set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/exampleApp.png") +endif() + +#------------------------------------------------------------------------------ +# and include CPack, so we get target for packages +include(CPack) diff --git a/projects/CMake/targets/GUCEF_tag_services/GUCEF_tag_services_ModuleDirs.cmake b/projects/CMake/targets/GUCEF_tag_services/GUCEF_tag_services_ModuleDirs.cmake index 7d1093fef..1b5fc9431 100644 --- a/projects/CMake/targets/GUCEF_tag_services/GUCEF_tag_services_ModuleDirs.cmake +++ b/projects/CMake/targets/GUCEF_tag_services/GUCEF_tag_services_ModuleDirs.cmake @@ -165,6 +165,7 @@ add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/SHARED/pluging add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/VFS/vfspluginAWSS3 ${CMAKE_BINARY_DIR}/vfspluginAWSS3 ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/VFS/vfspluginZIP ${CMAKE_BINARY_DIR}/vfspluginZIP ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/FilePusher ${CMAKE_BINARY_DIR}/FilePusher ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/FileSorter ${CMAKE_BINARY_DIR}/FileSorter ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/GucefLogServiceApp ${CMAKE_BINARY_DIR}/GucefLogServiceApp ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/GucefLogServiceClientPlugin ${CMAKE_BINARY_DIR}/GucefLogServiceClientPlugin ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/GucefLogServiceLib ${CMAKE_BINARY_DIR}/GucefLogServiceLib ) @@ -215,6 +216,7 @@ add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/SHARED/pluging add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/VFS/vfspluginAWSS3 ${CMAKE_BINARY_DIR}/vfspluginAWSS3 ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/VFS/vfspluginZIP ${CMAKE_BINARY_DIR}/vfspluginZIP ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/FilePusher ${CMAKE_BINARY_DIR}/FilePusher ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/FileSorter ${CMAKE_BINARY_DIR}/FileSorter ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/GucefLogServiceApp ${CMAKE_BINARY_DIR}/GucefLogServiceApp ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/GucefLogServiceClientPlugin ${CMAKE_BINARY_DIR}/GucefLogServiceClientPlugin ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/GucefLogServiceLib ${CMAKE_BINARY_DIR}/GucefLogServiceLib ) @@ -392,6 +394,7 @@ add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/SHARED/pluging add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/VFS/vfspluginAWSS3 ${CMAKE_BINARY_DIR}/vfspluginAWSS3 ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/VFS/vfspluginZIP ${CMAKE_BINARY_DIR}/vfspluginZIP ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/FilePusher ${CMAKE_BINARY_DIR}/FilePusher ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/FileSorter ${CMAKE_BINARY_DIR}/FileSorter ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/GucefLogServiceApp ${CMAKE_BINARY_DIR}/GucefLogServiceApp ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/GucefLogServiceClientPlugin ${CMAKE_BINARY_DIR}/GucefLogServiceClientPlugin ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/GucefLogServiceLib ${CMAKE_BINARY_DIR}/GucefLogServiceLib ) @@ -460,6 +463,7 @@ add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/SHARED/pluging add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/VFS/vfspluginAWSS3 ${CMAKE_BINARY_DIR}/vfspluginAWSS3 ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/VFS/vfspluginZIP ${CMAKE_BINARY_DIR}/vfspluginZIP ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/FilePusher ${CMAKE_BINARY_DIR}/FilePusher ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/FileSorter ${CMAKE_BINARY_DIR}/FileSorter ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/GucefLogServiceApp ${CMAKE_BINARY_DIR}/GucefLogServiceApp ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/GucefLogServiceClientPlugin ${CMAKE_BINARY_DIR}/GucefLogServiceClientPlugin ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/GucefLogServiceLib ${CMAKE_BINARY_DIR}/GucefLogServiceLib ) @@ -527,6 +531,7 @@ add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/SHARED/pluging add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/VFS/vfspluginAWSS3 ${CMAKE_BINARY_DIR}/vfspluginAWSS3 ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../plugins/VFS/vfspluginZIP ${CMAKE_BINARY_DIR}/vfspluginZIP ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/FilePusher ${CMAKE_BINARY_DIR}/FilePusher ) +add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/FileSorter ${CMAKE_BINARY_DIR}/FileSorter ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/GucefLogServiceApp ${CMAKE_BINARY_DIR}/GucefLogServiceApp ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/GucefLogServiceClientPlugin ${CMAKE_BINARY_DIR}/GucefLogServiceClientPlugin ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../../../../tools/GucefLogServiceLib ${CMAKE_BINARY_DIR}/GucefLogServiceLib ) diff --git a/projects/premake5/targets/GUCEF/premake5.lua b/projects/premake5/targets/GUCEF/premake5.lua index aed9d1a55..e8d0175c6 100644 --- a/projects/premake5/targets/GUCEF/premake5.lua +++ b/projects/premake5/targets/GUCEF/premake5.lua @@ -187,6 +187,7 @@ filter "ALL" include( "tools/FileDiff" ) include( "tools/FilePusher" ) include( "tools/FileReplacer" ) + include( "tools/FileSorter" ) include( "tools/GucefArchiver" ) include( "tools/GucefLogServiceApp" ) include( "tools/GucefLogServiceClientPlugin" ) diff --git a/projects/premake5/targets/GUCEF_exe_FileSorter/premake5.lua b/projects/premake5/targets/GUCEF_exe_FileSorter/premake5.lua new file mode 100644 index 000000000..5cd71cfa3 --- /dev/null +++ b/projects/premake5/targets/GUCEF_exe_FileSorter/premake5.lua @@ -0,0 +1,60 @@ +-------------------------------------------------------------------- +-- This file was automatically generated by ProjectGenerator +-- which is tooling part the build system designed for GUCEF +-- (Galaxy Unlimited Framework) +-- For the latest info, see http://www.VanvelzenSoftware.com/ +-- +-- The contents of this file are placed in the public domain. Feel +-- free to make use of it in any way you like. +-------------------------------------------------------------------- +-- + + +workspace( "GUCEF_exe_FileSorter" ) + + platforms( { "ALL" } ) + + location( "projects\premake5\targets" ) + + -- + -- Includes for all modules in the solution: + -- + +filter "ALL" + include( "dependencies/aws-cpp-sdk-core" ) + include( "dependencies/aws-cpp-sdk-s3" ) + include( "dependencies/aws-crt-cpp" ) + include( "dependencies/aws-crt-cpp/crt/aws-c-auth" ) + include( "dependencies/aws-crt-cpp/crt/aws-c-cal" ) + include( "dependencies/aws-crt-cpp/crt/aws-c-common" ) + include( "dependencies/aws-crt-cpp/crt/aws-c-compression" ) + include( "dependencies/aws-crt-cpp/crt/aws-c-event-stream" ) + include( "dependencies/aws-crt-cpp/crt/aws-c-http" ) + include( "dependencies/aws-crt-cpp/crt/aws-c-io" ) + include( "dependencies/aws-crt-cpp/crt/aws-c-mqtt" ) + include( "dependencies/aws-crt-cpp/crt/aws-c-s3" ) + include( "dependencies/aws-crt-cpp/crt/aws-c-sdkutils" ) + include( "dependencies/aws-crt-cpp/crt/aws-checksums" ) + include( "dependencies/curl" ) + include( "dependencies/json-builder" ) + include( "dependencies/json-parser" ) + include( "dependencies/libparsifal" ) + include( "dependencies/libyaml" ) + include( "dependencies/stbrumme-hash-library" ) + include( "dependencies/zlib" ) + include( "dependencies/zziplib" ) + include( "platform/gucefCOM" ) + include( "platform/gucefCOMCORE" ) + include( "platform/gucefCORE" ) + include( "platform/gucefMT" ) + include( "platform/gucefVFS" ) + include( "platform/gucefWEB" ) + include( "plugins/CORE/codecspluginSTBRUMMEHASH" ) + include( "plugins/CORE/codecspluginZLIB" ) + include( "plugins/CORE/dstorepluginJSONPARSER" ) + include( "plugins/CORE/dstorepluginPARSIFALXML" ) + include( "plugins/CORE/dstorepluginYAML" ) + include( "plugins/SHARED/pluginglueAWSSDK" ) + include( "plugins/VFS/vfspluginAWSS3" ) + include( "plugins/VFS/vfspluginZIP" ) + include( "tools/FileSorter" ) diff --git a/projects/premake5/targets/GUCEF_tag_services/premake5.lua b/projects/premake5/targets/GUCEF_tag_services/premake5.lua index c7c34e417..8c03e0031 100644 --- a/projects/premake5/targets/GUCEF_tag_services/premake5.lua +++ b/projects/premake5/targets/GUCEF_tag_services/premake5.lua @@ -71,6 +71,7 @@ filter "ALL" include( "plugins/VFS/vfspluginAWSS3" ) include( "plugins/VFS/vfspluginZIP" ) include( "tools/FilePusher" ) + include( "tools/FileSorter" ) include( "tools/GucefLogServiceApp" ) include( "tools/GucefLogServiceClientPlugin" ) include( "tools/GucefLogServiceLib" ) @@ -246,6 +247,7 @@ filter "LINUX32" include( "plugins/VFS/vfspluginAWSS3" ) include( "plugins/VFS/vfspluginZIP" ) include( "tools/FilePusher" ) + include( "tools/FileSorter" ) include( "tools/GucefLogServiceApp" ) include( "tools/GucefLogServiceClientPlugin" ) include( "tools/GucefLogServiceLib" ) @@ -297,6 +299,7 @@ filter "LINUX64" include( "plugins/VFS/vfspluginAWSS3" ) include( "plugins/VFS/vfspluginZIP" ) include( "tools/FilePusher" ) + include( "tools/FileSorter" ) include( "tools/GucefLogServiceApp" ) include( "tools/GucefLogServiceClientPlugin" ) include( "tools/GucefLogServiceLib" ) @@ -480,6 +483,7 @@ filter "WIN32" include( "plugins/VFS/vfspluginAWSS3" ) include( "plugins/VFS/vfspluginZIP" ) include( "tools/FilePusher" ) + include( "tools/FileSorter" ) include( "tools/GucefLogServiceApp" ) include( "tools/GucefLogServiceClientPlugin" ) include( "tools/GucefLogServiceLib" ) @@ -549,6 +553,7 @@ filter "WIN64" include( "plugins/VFS/vfspluginAWSS3" ) include( "plugins/VFS/vfspluginZIP" ) include( "tools/FilePusher" ) + include( "tools/FileSorter" ) include( "tools/GucefLogServiceApp" ) include( "tools/GucefLogServiceClientPlugin" ) include( "tools/GucefLogServiceLib" ) diff --git a/tools/FileSorter/Android.mk b/tools/FileSorter/Android.mk new file mode 100644 index 000000000..26d890d3f --- /dev/null +++ b/tools/FileSorter/Android.mk @@ -0,0 +1,48 @@ +#------------------------------------------------------------------- +# This file has been automatically generated by ProjectGenerator +# which is part of a build system designed for GUCEF +# (Galaxy Unlimited Framework) +# For the latest info, see http://www.VanvelzenSoftware.com/ +# +# The contents of this file are placed in the public domain. Feel +# free to make use of it in any way you like. +#------------------------------------------------------------------- + + +ifndef MY_MODULE_PATH + MY_MODULE_PATH := $(call my-dir) +endif +LOCAL_PATH := $(MY_MODULE_PATH) + +include $(CLEAR_VARS) + +@echo Module path: $(MY_MODULE_PATH) +LOCAL_MODULE := FileSorter +@echo Module name: $(LOCAL_MODULE) + +LOCAL_SRC_FILES := \ + src/FileSorter.cpp \ + src/main.cpp + +LOCAL_C_INCLUDES := \ + $(MY_MODULE_PATH)/include \ + $(MY_MODULE_PATH)/../../common/include \ + $(MY_MODULE_PATH)/../../platform/gucefCOM/include \ + $(MY_MODULE_PATH)/../../platform/gucefCOMCORE/include \ + $(MY_MODULE_PATH)/../../platform/gucefCORE/include \ + $(MY_MODULE_PATH)/../../platform/gucefCORE/include/android \ + $(MY_MODULE_PATH)/../../platform/gucefMT/include \ + $(MY_MODULE_PATH)/../../platform/gucefVFS/include \ + $(MY_MODULE_PATH)/../../platform/gucefWEB/include + + +LOCAL_SHARED_LIBRARIES := \ + gucefCOM \ + gucefCOMCORE \ + gucefCORE \ + gucefMT \ + gucefVFS \ + gucefWEB + +include $(BUILD_EXECUTABLE) + diff --git a/tools/FileSorter/CMakeLists.txt b/tools/FileSorter/CMakeLists.txt new file mode 100644 index 000000000..4b4d18ffc --- /dev/null +++ b/tools/FileSorter/CMakeLists.txt @@ -0,0 +1,90 @@ +#------------------------------------------------------------------- +# This file was automatically generated by ProjectGenerator +# which is tooling part the build system designed for GUCEF +# (Galaxy Unlimited Framework) +# For the latest info, see http://www.VanvelzenSoftware.com/ +# +# The contents of this file are placed in the public domain. Feel +# free to make use of it in any way you like. +#------------------------------------------------------------------- +# + +# Configuration for module: FileSorter + +set( HEADER_FILES + include/FileSorter.h +) + +set( SOURCE_FILES + src/FileSorter.cpp + src/main.cpp +) + +# Make sure the PLATFORM_HEADER_FILES variable is always defined + set( PLATFORM_HEADER_FILES "" ) + +# Make sure the PLATFORM_SOURCE_FILES variable is always defined + set( PLATFORM_SOURCE_FILES "" ) + +# For ease of use make a variable that has all files for this module +set( ALL_FILES ${HEADER_FILES} ${SOURCE_FILES} ${PLATFORM_HEADER_FILES} ${PLATFORM_SOURCE_FILES} ) + +set( MODULE_NAME "FileSorter" ) +if ( WIN32 ) + add_executable( ${MODULE_NAME} WIN32 ${ALL_FILES} ) +else() + add_executable( ${MODULE_NAME} ${ALL_FILES} ) +endif() +add_dependencies( ${MODULE_NAME} gucefCOM gucefCOMCORE gucefCORE gucefMT gucefVFS gucefWEB ) +target_link_libraries( ${MODULE_NAME} gucefCOM gucefCOMCORE gucefCORE gucefMT gucefVFS gucefWEB ) + +include_directories( ../../common/include ../../platform/gucefCOM/include ../../platform/gucefCOMCORE/include ../../platform/gucefCORE/include ../../platform/gucefMT/include ../../platform/gucefVFS/include ../../platform/gucefWEB/include include ) + +if ( ANDROID ) + include_directories( ../../platform/gucefCORE/include/android ) +endif( ANDROID ) + +if ( LINUX32 ) + include_directories( ../../platform/gucefCORE/include/linux ) +endif( LINUX32 ) + +if ( LINUX64 ) + include_directories( ../../platform/gucefCORE/include/linux ) +endif( LINUX64 ) + +if ( WIN32 ) + include_directories( ../../platform/gucefCOMCORE/include/mswin ../../platform/gucefCORE/include/mswin ../../platform/gucefMT/include/mswin ) +endif( WIN32 ) + +if ( WIN64 ) + include_directories( ../../platform/gucefCOMCORE/include/mswin ../../platform/gucefCORE/include/mswin ../../platform/gucefMT/include/mswin ) +endif( WIN64 ) + + + +#******** START OF AUTOGENERATED TEMPLATED ADDITION CONTENT ******** + + + + +if (ANDROID) +GUCEF_config_app( ${MODULE_NAME} ) +elseif (LINUX32) +GUCEF_config_app( ${MODULE_NAME} ) +elseif (LINUX64) +GUCEF_config_app( ${MODULE_NAME} ) +elseif (OSX) +GUCEF_config_app( ${MODULE_NAME} ) +elseif (WIN32) +GUCEF_config_app( ${MODULE_NAME} ) +elseif (WIN64) +GUCEF_config_app( ${MODULE_NAME} ) +else() +GUCEF_config_app( ${MODULE_NAME} ) +endif() + + + +#******** END OF AUTOGENERATED TEMPLATED ADDITION CONTENT ******** + + diff --git a/tools/FileSorter/FileSorter.ini b/tools/FileSorter/FileSorter.ini new file mode 100644 index 000000000..dba0b2e02 --- /dev/null +++ b/tools/FileSorter/FileSorter.ini @@ -0,0 +1,185 @@ + +[Bootstrap\PluginGroup] +"GroupName"="bootstrap" +"LoadImmediately"="true" + +;[Bootstrap\PluginGroup\PluginMetaData] +;"Description"="Client plugin for the GUCEf logging service" +;"Path"="$MODULEDIR$" +;"Filename"="GucefLogServiceClientPlugin" +;"Type"="GucefGenericPlugin" +;"Param"="logServiceAddress=127.0.0.1" +;"Param"="logServicePort=43557" + +[Bootstrap\PluginGroup\PluginMetaData] +"Description"="Data storage codec plugin which provides XML support using Parsifal XML" +"Path"="$MODULEDIR$" +"Filename"="dstorepluginPARSIFALXML" +"Type"="GucefDataStoreCodecPlugin" +"LoadFailAllowed"="true" + +[Bootstrap\PluginGroup\PluginMetaData] +"Description"="Data storage codec plugin which provides JSON support using json-parser and json-builder" +"Path"="$MODULEDIR$" +"Filename"="dstorepluginJSONPARSER" +"Type"="GucefDataStoreCodecPlugin" +"LoadFailAllowed"="true" + +[Bootstrap\PluginGroup\PluginMetaData] +"Description"="Data storage codec plugin which provides YAML support using LIBYAML" +"Path"="$MODULEDIR$" +"Filename"="dstorepluginYAML" +"Type"="GucefDataStoreCodecPlugin" +"LoadFailAllowed"="true" + +[Bootstrap\PluginGroup\PluginMetaData] +"Description"="compression and checksum codecs for zlib/gzip/deflate/crc32/adler32" +"Path"="$MODULEDIR$" +"Filename"="codecspluginZLIB" +"AltFilename"="codecspluginZLIB_d" +"Type"="GucefStandardCodecPlugin" +"LoadFailAllowed"="false" + +;[Bootstrap\PluginGroup\PluginMetaData] +;"Description"="plugin providing VFS archive support for AWS S3 buckets" +;"Path"="$MODULEDIR$" +;"Filename"="vfspluginAWSS3" +;"AltFilename"="vfspluginAWSS3_d" +;"Type"="GucefGenericPlugin" +;"LoadFailAllowed"="true" + +[VFS] +"maxmemload"="1024" +"asyncOpsThreadpool"="VFS" +"asyncOpsMinWorkerThreads"="1" + +[VFS] +"maxmemload"="1024" +"asyncOpsThreadpool"="VFS" +"asyncOpsMinWorkerThreads"="48" + +[VFS\Archives\ArchiveSettings] +"actualArchivePath"="$MODULEDIR$" +"mountPath"="InstallPath" +"archiveName"="InstallPath" +"archiveType"="FileSystem" +"mountArchives"="false" +"mountArchivesIsRecursive"="false" +"writeable"="true" +"readable"="true" + +[VFS\Archives\ArchiveSettings] +"actualArchivePath"="C:\_examplePath_\" +"mountPath"="SortPath" +"archiveName"="SortPath" +"archiveType"="FileSystem" +"mountArchives"="false" +"mountArchivesIsRecursive"="false" +"writeable"="true" +"readable"="true" + +;[VFS\Archives\ArchiveSettings] +;"actualArchivePath"="/aws/s3/" +;"mountPath"="/aws/s3/" +;"archiveName"="AWS::S3" +;"archiveType"="AWS::S3" +;"mountArchives"="false" +;"mountArchivesIsRecursive"="false" +;"writeable"="true" +;"readable"="true" + +;[VFS\Archives\ArchiveSettings] +;"actualArchivePath"="/aws/s3/examplebucket" +;"mountPath"="/aws/s3/examplebucket" +;"archiveName"="examplebucket" +;"archiveType"="AWS::S3::Bucket" +;"mountArchives"="false" +;"mountArchivesIsRecursive"="false" +;"writeable"="true" +;"readable"="true" + +;[AWSSDK] +;"AWS_ACCESS_KEY_ID"="" +;"AWS_SECRET_ACCESS_KEY"="" +;"AWS_SESSION_TOKEN"="" +;"AWSCredentialsProviders"="Environment;Config;ProfileConfigFile;InstanceProfile" +;"DefaultClientConfig.region"="us-east-2" +;"LogLevel"="5" + +[GlobalDnsCache] +"asyncRefreshIntervalInMs"=300000 +"asyncUpdateCache"="true" + +[StatsDClient] +"statsDestination"="127.0.0.1:8125" +"statsNamePrefix"="$HOSTNAME$." +"statsInterface"="" +"transmit"="false" +"logStats"="false" + +[FileSorter\FileSorterConfig] +"vfsInboxPath"="SortPath/autosort" +"vfsSortSourceRootPath"="SortPath/unsorted" +"vfsSortedTargetRootPath"="SortPath/sorted" +"dirStructureUtcOffsetInMins"="-360" +"useDateTimeFolderStructure"="true" +"yearFolderDecoration"="-== {year} ==-" +"useMonthFolder"="false" +"monthFolderDecoration"="-== {month}. {monthName} ==-" +"useDayFolder"="true" +"dayFolderDecoration"="{month}.{day}.{year}" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="image" +"extensions"="png,jpg,jpeg,gif" +"sortFolderName"="-== Pics ==-" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="video" +"extensions"="mp4,divx,xvid,mpeg,avi" +"sortFolderName"="-== Video ==-" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="audio" +"extensions"="mp3,wav" +"sortFolderName"="-== Audio ==-" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="spreadsheet" +"extensions"="xls" +"sortFolderName"="-== Docs ==-" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="presentation" +"extensions"="ppt" +"sortFolderName"="-== Docs ==-" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="document" +"extensions"="doc,docx,pdf,odt" +"sortFolderName"="-== Docs ==-" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="configuration" +"extensions"="ini" +"sortFolderName"="-== Docs ==-" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="compressed" +"extensions"="zip,rar,gzip" +"sortFolderName"="-== Archives ==-" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="archive" +"extensions"="iso" +"sortFolderName"="-== Archives ==-" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="unknown" +"extensions"="" +"sortFolderName"="-== Misc ==-" + +[Main\AppArgs] +"outputDir"="$MODULEDIR$" +"RestApiPort"="10000" +"RestBasicHealthUri"="/health/basic" diff --git a/tools/FileSorter/FileSorter_d.ini b/tools/FileSorter/FileSorter_d.ini new file mode 100644 index 000000000..1cf6a174b --- /dev/null +++ b/tools/FileSorter/FileSorter_d.ini @@ -0,0 +1,185 @@ + +[Bootstrap\PluginGroup] +"GroupName"="bootstrap" +"LoadImmediately"="true" + +;[Bootstrap\PluginGroup\PluginMetaData] +;"Description"="Client plugin for the GUCEF logging service" +;"Path"="$MODULEDIR$" +;"Filename"="GucefLogServiceClientPlugin_d" +;"Type"="GucefGenericPlugin" +;"Param"="logServiceAddress=127.0.0.1" +;"Param"="logServicePort=43557" + +[Bootstrap\PluginGroup\PluginMetaData] +"Description"="Data storage codec plugin which provides XML support using Parsifal XML" +"Path"="$MODULEDIR$" +"Filename"="dstorepluginPARSIFALXML_d" +"Type"="GucefDataStoreCodecPlugin" +"LoadFailAllowed"="true" + +[Bootstrap\PluginGroup\PluginMetaData] +"Description"="Data storage codec plugin which provides JSON support using json-parser and json-builder" +"Path"="$MODULEDIR$" +"Filename"="dstorepluginJSONPARSER_d" +"Type"="GucefDataStoreCodecPlugin" +"LoadFailAllowed"="true" + +[Bootstrap\PluginGroup\PluginMetaData] +"Description"="Data storage codec plugin which provides YAML support using LIBYAML" +"Path"="$MODULEDIR$" +"Filename"="dstorepluginYAML_d" +"Type"="GucefDataStoreCodecPlugin" +"LoadFailAllowed"="true" + +[Bootstrap\PluginGroup\PluginMetaData] +"Description"="compression and checksum codecs for zlib/gzip/deflate/crc32/adler32" +"Path"="$MODULEDIR$" +"Filename"="codecspluginZLIB_d" +"AltFilename"="codecspluginZLIB" +"Type"="GucefStandardCodecPlugin" +"LoadFailAllowed"="false" + +;[Bootstrap\PluginGroup\PluginMetaData] +;"Description"="plugin providing VFS archive support for AWS S3 buckets" +;"Path"="$MODULEDIR$" +;"Filename"="vfspluginAWSS3_d" +;"AltFilename"="vfspluginAWSS3" +;"Type"="GucefGenericPlugin" +;"LoadFailAllowed"="true" + +[VFS] +"maxmemload"="1024" +"asyncOpsThreadpool"="VFS" +"asyncOpsMinWorkerThreads"="1" + +[VFS] +"maxmemload"="1024" +"asyncOpsThreadpool"="VFS" +"asyncOpsMinWorkerThreads"="48" + +[VFS\Archives\ArchiveSettings] +"actualArchivePath"="$MODULEDIR$" +"mountPath"="InstallPath" +"archiveName"="InstallPath" +"archiveType"="FileSystem" +"mountArchives"="false" +"mountArchivesIsRecursive"="false" +"writeable"="true" +"readable"="true" + +[VFS\Archives\ArchiveSettings] +"actualArchivePath"="C:\_examplePath_\" +"mountPath"="SortPath" +"archiveName"="SortPath" +"archiveType"="FileSystem" +"mountArchives"="false" +"mountArchivesIsRecursive"="false" +"writeable"="true" +"readable"="true" + +;[VFS\Archives\ArchiveSettings] +;"actualArchivePath"="/aws/s3/" +;"mountPath"="/aws/s3/" +;"archiveName"="AWS::S3" +;"archiveType"="AWS::S3" +;"mountArchives"="false" +;"mountArchivesIsRecursive"="false" +;"writeable"="true" +;"readable"="true" + +;[VFS\Archives\ArchiveSettings] +;"actualArchivePath"="/aws/s3/examplebucket" +;"mountPath"="/aws/s3/examplebucket" +;"archiveName"="examplebucket" +;"archiveType"="AWS::S3::Bucket" +;"mountArchives"="false" +;"mountArchivesIsRecursive"="false" +;"writeable"="true" +;"readable"="true" + +;[AWSSDK] +;"AWS_ACCESS_KEY_ID"="" +;"AWS_SECRET_ACCESS_KEY"="" +;"AWS_SESSION_TOKEN"="" +;"AWSCredentialsProviders"="Environment;Config;ProfileConfigFile;InstanceProfile" +;"DefaultClientConfig.region"="us-east-2" +;"LogLevel"="5" + +[GlobalDnsCache] +"asyncRefreshIntervalInMs"=300000 +"asyncUpdateCache"="true" + +[StatsDClient] +"statsDestination"="127.0.0.1:8125" +"statsNamePrefix"="$HOSTNAME$." +"statsInterface"="" +"transmit"="false" +"logStats"="false" + +[FileSorter\FileSorterConfig] +"vfsInboxPath"="SortPath/autosort" +"vfsSortSourceRootPath"="SortPath/unsorted" +"vfsSortedTargetRootPath"="SortPath/sorted" +"dirStructureUtcOffsetInMins"="-360" +"useDateTimeFolderStructure"="true" +"yearFolderDecoration"="-== {year} ==-" +"useMonthFolder"="false" +"monthFolderDecoration"="-== {month}. {monthName} ==-" +"useDayFolder"="true" +"dayFolderDecoration"="{month}.{day}.{year}" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="image" +"extensions"="png,jpg,jpeg,gif" +"sortFolderName"="-== Pics ==-" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="video" +"extensions"="mp4,divx,xvid,mpeg,avi" +"sortFolderName"="-== Video ==-" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="audio" +"extensions"="mp3,wav" +"sortFolderName"="-== Audio ==-" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="spreadsheet" +"extensions"="xls" +"sortFolderName"="-== Docs ==-" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="presentation" +"extensions"="ppt" +"sortFolderName"="-== Docs ==-" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="document" +"extensions"="doc,docx,pdf,odt" +"sortFolderName"="-== Docs ==-" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="configuration" +"extensions"="ini" +"sortFolderName"="-== Docs ==-" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="compressed" +"extensions"="zip,rar,gzip" +"sortFolderName"="-== Archives ==-" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="archive" +"extensions"="iso" +"sortFolderName"="-== Archives ==-" + +[FileSorter\FileSorterConfig\FileTypeConfig\FileTypes\FileType] +"type"="unknown" +"extensions"="" +"sortFolderName"="-== Misc ==-" + +[Main\AppArgs] +"outputDir"="$MODULEDIR$" +"RestApiPort"="10000" +"RestBasicHealthUri"="/health/basic" diff --git a/tools/FileSorter/ModuleInfo.xml b/tools/FileSorter/ModuleInfo.xml new file mode 100644 index 000000000..e468c0e53 --- /dev/null +++ b/tools/FileSorter/ModuleInfo.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/FileSorter/include/FileSorter.h b/tools/FileSorter/include/FileSorter.h new file mode 100644 index 000000000..c86ff67a2 --- /dev/null +++ b/tools/FileSorter/include/FileSorter.h @@ -0,0 +1,281 @@ +/* + * FileSorter: service which sorts files + * + * Copyright (C) 1998 - 2024. Dinand Vanvelzen + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GUCEF_APP_FILESORTER_H +#define GUCEF_APP_FILESORTER_H + +/*-------------------------------------------------------------------------// +// // +// INCLUDES // +// // +//-------------------------------------------------------------------------*/ + +#ifndef GUCEF_CORE_CICONFIGURABLE_H +#include "CIConfigurable.h" +#define GUCEF_CORE_CICONFIGURABLE_H +#endif /* GUCEF_CORE_CICONFIGURABLE_H ? */ + +#ifndef GUCEF_CORE_CVALUELIST_H +#include "CValueList.h" +#define GUCEF_CORE_CVALUELIST_H +#endif /* GUCEF_CORE_CVALUELIST_H ? */ + +#ifndef GUCEF_CORE_CDATANODE_H +#include "CDataNode.h" +#define GUCEF_CORE_CDATANODE_H +#endif /* GUCEF_CORE_CDATANODE_H ? */ + +#ifndef GUCEF_CORE_CTIMER_H +#include "CTimer.h" +#define GUCEF_CORE_CTIMER_H +#endif /* GUCEF_CORE_CTIMER_H ? */ + +#ifndef GUCEF_CORE_CDATETIME_H +#include "gucefCORE_CDateTime.h" +#define GUCEF_CORE_CDATETIME_H +#endif /* GUCEF_CORE_CDATETIME_H ? */ + +#ifndef GUCEF_CORE_CFILESYSTEMDIRECTORYWATCHER_H +#include "gucefCORE_CFileSystemDirectoryWatcher.h" +#define GUCEF_CORE_CFILESYSTEMDIRECTORYWATCHER_H +#endif /* GUCEF_CORE_CFILESYSTEMDIRECTORYWATCHER_H ? */ + +#ifndef GUCEF_WEB_CHTTPSERVER_H +#include "gucefWEB_CHTTPServer.h" +#define GUCEF_WEB_CHTTPSERVER_H +#endif /* GUCEF_WEB_CHTTPSERVER_H ? */ + +#ifndef GUCEF_WEB_CHTTPCLIENT_H +#include "gucefWEB_CHTTPClient.h" +#define GUCEF_WEB_CHTTPCLIENT_H +#endif /* GUCEF_WEB_CHTTPCLIENT_H ? */ + +#ifndef GUCEF_WEB_CDEFAULTHTTPSERVERROUTER_H +#include "gucefWEB_CDefaultHTTPServerRouter.h" +#define GUCEF_WEB_CDEFAULTHTTPSERVERROUTER_H +#endif /* GUCEF_WEB_CDEFAULTHTTPSERVERROUTER_H ? */ + +#ifndef GUCEF_WEB_CCODECBASEDHTTPSERVERRESOURCE_H +#include "gucefWEB_CCodecBasedHTTPServerResource.h" +#define GUCEF_WEB_CCODECBASEDHTTPSERVERRESOURCE_H +#endif /* GUCEF_WEB_CCODECBASEDHTTPSERVERRESOURCE_H ? */ + +#ifndef GUCEF_WEB_CTASKMANAGERSERVERRESOURCE_H +#include "gucefWEB_CTaskManagerServerResource.h" +#define GUCEF_WEB_CTASKMANAGERSERVERRESOURCE_H +#endif /* GUCEF_WEB_CTASKMANAGERSERVERRESOURCE_H ? */ + +/*-------------------------------------------------------------------------// +// // +// NAMESPACE // +// // +//-------------------------------------------------------------------------*/ + +using namespace GUCEF; + +/*-------------------------------------------------------------------------// +// // +// UTILITIES // +// // +//-------------------------------------------------------------------------*/ + +class FileSorter; + +class RestApiFileSorterInfoResource : public WEB::CCodecBasedHTTPServerResource +{ + public: + + RestApiFileSorterInfoResource( FileSorter* app ); + + virtual ~RestApiFileSorterInfoResource(); + + virtual bool Serialize( CORE::CDataNode& output , + const CORE::CString& representation ); + + private: + + FileSorter* m_app; +}; + +/*-------------------------------------------------------------------------*/ + +class RestApiFileSorterConfigResource : public WEB::CCodecBasedHTTPServerResource +{ + public: + + RestApiFileSorterConfigResource( FileSorter* app, bool appConfig ); + + virtual ~RestApiFileSorterConfigResource(); + + virtual bool Serialize( CORE::CDataNode& output , + const CORE::CString& representation ); + + private: + + FileSorter* m_app; + bool m_appConfig; +}; + +/*-------------------------------------------------------------------------*/ + +enum EFileType +{ + FILETYPE_UNKNOWN = 0, + + FILETYPE_TEXT = 1, + FILETYPE_BINARY = 2, + FILETYPE_IMAGE = 3, + FILETYPE_AUDIO = 4, + FILETYPE_VIDEO = 5, + FILETYPE_ARCHIVE = 6, + FILETYPE_DOCUMENT, + FILETYPE_PRESENTATION, + FILETYPE_SPREADSHEET, + FILETYPE_DATABASE, + FILETYPE_EXECUTABLE, + FILETYPE_SCRIPT, + FILETYPE_WEBPAGE, + FILETYPE_SOURCECODE, + FILETYPE_CONFIGURATION, + FILETYPE_LOG, + FILETYPE_TEMPORARY, + FILETYPE_COMPRESSED, + FILETYPE_OTHER +}; +typedef enum EFileType TFileType; + +typedef std::map< CORE::CString, TFileType > TStringToFileTypeMap; +typedef std::map< TFileType, CORE::CString > TFileTypeToStringMap; + +/*-------------------------------------------------------------------------*/ + +class FileTypeConfig : public CORE::CIConfigurable +{ + public: + + static const CORE::CString ClassTypeName; + + FileTypeConfig( void ); + + virtual ~FileTypeConfig(); + + virtual bool SaveConfig( CORE::CDataNode& cfg ) const GUCEF_VIRTUAL_OVERRIDE; + + virtual bool LoadConfig( const CORE::CDataNode& cfg ) GUCEF_VIRTUAL_OVERRIDE; + + virtual const CORE::CString& GetClassTypeName( void ) const GUCEF_VIRTUAL_OVERRIDE; + + TFileType GetFileTypeForFileExtension( const CORE::CString& fileExt ) const; + + TFileType GetFileTypeForString( const CORE::CString& fileTypeStr ) const; + + const CORE::CString& GetSortRootFolderForFileType( TFileType fileType ) const; + + const CORE::CString& GetSortRootFolderForFileExtension( const CORE::CString& fileExt ) const; + + private: + + TStringToFileTypeMap m_fileExtToTypeMap; + TFileTypeToStringMap m_typeToSortFolderMap; +}; + +/*-------------------------------------------------------------------------*/ + +class FileSorterConfig : public CORE::CGloballyConfigurable +{ + public: + + static const CORE::CString ClassTypeName; + + FileSorterConfig( void ); + + virtual ~FileSorterConfig(); + + virtual bool SaveConfig( CORE::CDataNode& cfg ) const GUCEF_VIRTUAL_OVERRIDE; + + virtual bool LoadConfig( const CORE::CDataNode& cfg ) GUCEF_VIRTUAL_OVERRIDE; + + virtual const CORE::CString& GetClassTypeName( void ) const GUCEF_VIRTUAL_OVERRIDE; + + FileTypeConfig fileTypeConfig; + CORE::CString vfsInboxPath; + CORE::CString vfsSortSourceRootPath; + CORE::CString vfsSortedTargetRootPath; + bool useDateTimeFolderStructure; + CORE::Int16 dirStructureUtcOffsetInMins; + CORE::CString yearFolderDecoration; + bool useMonthFolder; + CORE::CString monthFolderDecoration; + bool useDayFolder; + CORE::CString dayFolderDecoration; + + private: + +}; + +/*-------------------------------------------------------------------------*/ + +class FileSorter : public CORE::CTSGNotifier +{ + public: + + FileSorter( void ); + virtual ~FileSorter(); + + bool Start( void ); + + bool LoadConfig( const CORE::CValueList& appArgs , + const CORE::CDataNode& globalConfig ); + + const FileSorterConfig& GetAppConfig( void ) const; + + const CORE::CDataNode& GetGlobalConfig( void ) const; + + private: + + typedef CORE::CTEventHandlerFunctor< FileSorter > TEventCallback; + + void RegisterEventHandlers( void ); + + bool SortFile( const CORE::CString& currentVfsFilePath ); + + bool SortInitialRootPaths( void ); + + bool SortFilesInVfsPath( const CORE::CString& vfsRootPath ); + + void OnAppStarted( CORE::CNotifier* notifier , + const CORE::CEvent& eventId , + CORE::CICloneable* eventData ); + + void OnVfsInitializationCompleted( CORE::CNotifier* notifier , + const CORE::CEvent& eventId , + CORE::CICloneable* eventData ); + + private: + + WEB::CHTTPServer m_httpServer; + WEB::CDefaultHTTPServerRouter m_httpRouter; + WEB::CTaskManagerServerResource m_taskManagementRsc; + CORE::CDataNode m_globalConfig; + CORE::CValueList m_appArgs; + FileSorterConfig m_appConfig; +}; + +/*-------------------------------------------------------------------------*/ + +#endif /* GUCEF_APP_FILESORTER_H ? */ diff --git a/tools/FileSorter/premake4.lua b/tools/FileSorter/premake4.lua new file mode 100644 index 000000000..58b973dc3 --- /dev/null +++ b/tools/FileSorter/premake4.lua @@ -0,0 +1,74 @@ +-------------------------------------------------------------------- +-- This file was automatically generated by ProjectGenerator +-- which is tooling part the build system designed for GUCEF +-- (Galaxy Unlimited Framework) +-- For the latest info, see http://www.VanvelzenSoftware.com/ +-- +-- The contents of this file are placed in the public domain. Feel +-- free to make use of it in any way you like. +-------------------------------------------------------------------- +-- + +-- Configuration for module: FileSorter + + +project( "FileSorter" ) + +configuration( {} ) + location( os.getenv( "PM4OUTPUTDIR" ) ) + +configuration( {} ) + targetdir( os.getenv( "PM4TARGETDIR" ) ) + +configuration( {} ) +language( "C++" ) + +configuration( { "WIN32" } ) + + +configuration( { WIN32 } ) +kind( "WindowedApp" ) +configuration( { "NOT WIN32" } ) + + +configuration( {} ) +kind( "ConsoleApp" ) + +configuration( {} ) +links( { "gucefCOM", "gucefCOMCORE", "gucefCORE", "gucefMT", "gucefVFS", "gucefWEB" } ) +links( { "gucefCOM", "gucefCOMCORE", "gucefCORE", "gucefMT", "gucefVFS", "gucefWEB" } ) + + +configuration( {} ) +vpaths { ["Headers"] = { "**.h", "**.hpp", "**.hxx" } } +files( { + "include/FileSorter.h" + } ) + + + +configuration( {} ) +vpaths { ["Source"] = { "**.c", "**.cpp", "**.cs", "**.asm" } } +files( { + "src/FileSorter.cpp", + "src/main.cpp" + } ) + + +configuration( {} ) +includedirs( { "../../common/include", "../../platform/gucefCOM/include", "../../platform/gucefCOMCORE/include", "../../platform/gucefCORE/include", "../../platform/gucefMT/include", "../../platform/gucefVFS/include", "../../platform/gucefWEB/include", "include" } ) + +configuration( { "ANDROID" } ) +includedirs( { "../../platform/gucefCORE/include/android" } ) + +configuration( { "LINUX32" } ) +includedirs( { "../../platform/gucefCORE/include/linux" } ) + +configuration( { "LINUX64" } ) +includedirs( { "../../platform/gucefCORE/include/linux" } ) + +configuration( { "WIN32" } ) +includedirs( { "../../platform/gucefCOMCORE/include/mswin", "../../platform/gucefCORE/include/mswin", "../../platform/gucefMT/include/mswin" } ) + +configuration( { "WIN64" } ) +includedirs( { "../../platform/gucefCOMCORE/include/mswin", "../../platform/gucefCORE/include/mswin", "../../platform/gucefMT/include/mswin" } ) diff --git a/tools/FileSorter/premake5.lua b/tools/FileSorter/premake5.lua new file mode 100644 index 000000000..558bbc0b8 --- /dev/null +++ b/tools/FileSorter/premake5.lua @@ -0,0 +1,74 @@ +-------------------------------------------------------------------- +-- This file was automatically generated by ProjectGenerator +-- which is tooling part the build system designed for GUCEF +-- (Galaxy Unlimited Framework) +-- For the latest info, see http://www.VanvelzenSoftware.com/ +-- +-- The contents of this file are placed in the public domain. Feel +-- free to make use of it in any way you like. +-------------------------------------------------------------------- +-- + +-- Configuration for module: FileSorter + + +project( "FileSorter" ) + +configuration( {} ) + location( os.getenv( "PM5OUTPUTDIR" ) ) + +configuration( {} ) + targetdir( os.getenv( "PM5TARGETDIR" ) ) + +configuration( {} ) +language( "C++" ) + +configuration( { "WIN32" } ) + + +configuration( { WIN32 } ) +kind( "WindowedApp" ) +configuration( { "NOT WIN32" } ) + + +configuration( {} ) +kind( "ConsoleApp" ) + +configuration( {} ) +links( { "gucefCOM", "gucefCOMCORE", "gucefCORE", "gucefMT", "gucefVFS", "gucefWEB" } ) +links( { "gucefCOM", "gucefCOMCORE", "gucefCORE", "gucefMT", "gucefVFS", "gucefWEB" } ) + + +configuration( {} ) +vpaths { ["Headers"] = { "**.h", "**.hpp", "**.hxx" } } +files( { + "include/FileSorter.h" + } ) + + + +configuration( {} ) +vpaths { ["Source"] = { "**.c", "**.cpp", "**.cs", "**.asm" } } +files( { + "src/FileSorter.cpp", + "src/main.cpp" + } ) + + +configuration( {} ) +includedirs( { "../../common/include", "../../platform/gucefCOM/include", "../../platform/gucefCOMCORE/include", "../../platform/gucefCORE/include", "../../platform/gucefMT/include", "../../platform/gucefVFS/include", "../../platform/gucefWEB/include", "include" } ) + +configuration( { "ANDROID" } ) +includedirs( { "../../platform/gucefCORE/include/android" } ) + +configuration( { "LINUX32" } ) +includedirs( { "../../platform/gucefCORE/include/linux" } ) + +configuration( { "LINUX64" } ) +includedirs( { "../../platform/gucefCORE/include/linux" } ) + +configuration( { "WIN32" } ) +includedirs( { "../../platform/gucefCOMCORE/include/mswin", "../../platform/gucefCORE/include/mswin", "../../platform/gucefMT/include/mswin" } ) + +configuration( { "WIN64" } ) +includedirs( { "../../platform/gucefCOMCORE/include/mswin", "../../platform/gucefCORE/include/mswin", "../../platform/gucefMT/include/mswin" } ) diff --git a/tools/FileSorter/src/FileSorter.cpp b/tools/FileSorter/src/FileSorter.cpp new file mode 100644 index 000000000..114c24a7f --- /dev/null +++ b/tools/FileSorter/src/FileSorter.cpp @@ -0,0 +1,656 @@ +/* + * FileSorter: service which sorts files + * + * Copyright (C) 1998 - 2024. Dinand Vanvelzen + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*-------------------------------------------------------------------------// +// // +// INCLUDES // +// // +//-------------------------------------------------------------------------*/ + +#ifndef GUCEF_CORE_CTASKMANAGER_H +#include "gucefCORE_CTaskManager.h" +#define GUCEF_CORE_CTASKMANAGER_H +#endif /* GUCEF_CORE_CTASKMANAGER_H */ + +#ifndef GUCEF_CORE_CGUCEFAPPLICATION_H +#include "CGUCEFApplication.h" +#define GUCEF_CORE_CGUCEFAPPLICATION_H +#endif /* GUCEF_CORE_CGUCEFAPPLICATION_H ? */ + +#ifndef GUCEF_CORE_METRICSMACROS_H +#include "gucefCORE_MetricsMacros.h" +#define GUCEF_CORE_METRICSMACROS_H +#endif /* GUCEF_CORE_METRICSMACROS_H ? */ + +#ifndef GUCEF_CORE_DVFILEUTILS_H +#include "dvfileutils.h" +#define GUCEF_CORE_DVFILEUTILS_H +#endif /* GUCEF_CORE_DVFILEUTILS_H ? */ + +#ifndef GUCEF_CORE_DVCPPFILEUTILS_H +#include "dvcppfileutils.h" +#define GUCEF_CORE_DVCPPFILEUTILS_H +#endif /* GUCEF_CORE_DVCPPFILEUTILS_H ? */ + +#ifndef GUCEF_CORE_CFILEACCESS_H +#include "CFileAccess.h" +#define GUCEF_CORE_CFILEACCESS_H +#endif /* GUCEF_CORE_CFILEACCESS_H ? */ + +#ifndef GUCEF_CORE_CORECODECTYPES_H +#include "gucefCORE_CoreCodecTypes.h" +#define GUCEF_CORE_CORECODECTYPES_H +#endif /* GUCEF_CORE_CORECODECTYPES_H ? */ + +#ifndef GUCEF_VFS_CVFSGLOBAL_H +#include "gucefVFS_CVfsGlobal.h" +#define GUCEF_VFS_CVFSGLOBAL_H +#endif /* GUCEF_VFS_CVFSGLOBAL_H ? */ + +#ifndef GUCEF_VFS_CVFS_H +#include "gucefVFS_CVFS.h" +#define GUCEF_VFS_CVFS_H +#endif /* GUCEF_VFS_CVFS_H ? */ + +#ifndef GUCEF_WEB_CDUMMYHTTPSERVERRESOURCE_H +#include "gucefWEB_CDummyHTTPServerResource.h" +#define GUCEF_WEB_CDUMMYHTTPSERVERRESOURCE_H +#endif /* GUCEF_WEB_CDUMMYHTTPSERVERRESOURCE_H ? */ + +#ifndef GUCEF_WEB_CHTTPENCODINGTYPES_H +#include "gucefWEB_CHttpEncodingTypes.h" +#define GUCEF_WEB_CHTTPENCODINGTYPES_H +#endif /* GUCEF_WEB_CHTTPENCODINGTYPES_H ? */ + +#include "FileSorter.h" + +/*-------------------------------------------------------------------------// +// // +// IMPLEMENTATION // +// // +//-------------------------------------------------------------------------*/ + +RestApiFileSorterInfoResource::RestApiFileSorterInfoResource( FileSorter* app ) + : WEB::CCodecBasedHTTPServerResource() + , m_app( app ) +{GUCEF_TRACE; + + m_allowSerialize = true; +} + +/*-------------------------------------------------------------------------*/ + +RestApiFileSorterInfoResource::~RestApiFileSorterInfoResource() +{GUCEF_TRACE; + +} + +/*-------------------------------------------------------------------------*/ + +bool +RestApiFileSorterInfoResource::Serialize( CORE::CDataNode& output , + const CORE::CString& representation ) +{GUCEF_TRACE; + + output.SetName( "info" ); + output.SetAttribute( "application", "FileSorter" ); + output.SetAttribute( "buildDateTime", __TIMESTAMP__ ); + #ifdef GUCEF_DEBUG_MODE + output.SetAttribute( "isReleaseBuild", "false" ); + #else + output.SetAttribute( "isReleaseBuild", "true" ); + #endif + return true; +} + +/*-------------------------------------------------------------------------*/ + +RestApiFileSorterConfigResource::RestApiFileSorterConfigResource( FileSorter* app, bool appConfig ) + : WEB::CCodecBasedHTTPServerResource() + , m_app( app ) + , m_appConfig( appConfig ) +{GUCEF_TRACE; + + m_allowSerialize = true; +} + +/*-------------------------------------------------------------------------*/ + +RestApiFileSorterConfigResource::~RestApiFileSorterConfigResource() +{GUCEF_TRACE; + +} + +/*-------------------------------------------------------------------------*/ + +bool +RestApiFileSorterConfigResource::Serialize( CORE::CDataNode& output , + const CORE::CString& representation ) +{GUCEF_TRACE; + + if ( m_appConfig ) + { + const FileSorterConfig& loadedConfig = m_app->GetAppConfig(); + return loadedConfig.SaveConfig( output ); + } + + const CORE::CDataNode& globalConfig = m_app->GetGlobalConfig(); + output.Copy( globalConfig ); + return true; +} + +/*-------------------------------------------------------------------------*/ + +const CORE::CString FileTypeConfig::ClassTypeName = "FileTypeConfig"; + +/*-------------------------------------------------------------------------*/ + +FileTypeConfig::FileTypeConfig( void ) + : CORE::CIConfigurable() + , m_fileExtToTypeMap() + , m_typeToSortFolderMap() +{GUCEF_TRACE; +} + +/*-------------------------------------------------------------------------*/ + +FileTypeConfig::~FileTypeConfig() +{GUCEF_TRACE; +} + +/*-------------------------------------------------------------------------*/ + +bool +FileTypeConfig::SaveConfig( CORE::CDataNode& cfg ) const +{GUCEF_TRACE; + + return false; +} + +/*-------------------------------------------------------------------------*/ + +const CORE::CString& +FileTypeConfig::GetClassTypeName( void ) const +{GUCEF_TRACE; + + return ClassTypeName; +} + +/*-------------------------------------------------------------------------*/ + +TFileType +FileTypeConfig::GetFileTypeForString( const CORE::CString& fileTypeStr ) const +{GUCEF_TRACE; + + const CORE::CString& fileTypeStrLc = fileTypeStr.Lowercase(); + + if ( "text" == fileTypeStrLc ) + return FILETYPE_TEXT; + if ( "binary" == fileTypeStrLc ) + return FILETYPE_BINARY; + if ( "image" == fileTypeStrLc ) + return FILETYPE_IMAGE; + if ( "audio" == fileTypeStrLc ) + return TFileType::FILETYPE_AUDIO; + if ( "video" == fileTypeStrLc ) + return TFileType::FILETYPE_VIDEO; + if ( "archive" == fileTypeStrLc ) + return TFileType::FILETYPE_ARCHIVE; + if ( "document" == fileTypeStrLc ) + return TFileType::FILETYPE_DOCUMENT; + if ( "presentation" == fileTypeStrLc ) + return TFileType::FILETYPE_PRESENTATION; + if ( "spreadsheet" == fileTypeStrLc ) + return TFileType::FILETYPE_SPREADSHEET; + if ( "database" == fileTypeStrLc ) + return TFileType::FILETYPE_DATABASE; + if ( "database" == fileTypeStrLc ) + return TFileType::FILETYPE_DATABASE; + if ( "executable" == fileTypeStrLc ) + return TFileType::FILETYPE_EXECUTABLE; + if ( "script" == fileTypeStrLc ) + return TFileType::FILETYPE_SCRIPT; + if ( "webpage" == fileTypeStrLc ) + return TFileType::FILETYPE_WEBPAGE; + if ( "sourcecode" == fileTypeStrLc ) + return TFileType::FILETYPE_SOURCECODE; + if ( "configuration" == fileTypeStrLc ) + return TFileType::FILETYPE_CONFIGURATION; + if ( "log" == fileTypeStrLc ) + return TFileType::FILETYPE_LOG; + if ( "temporary" == fileTypeStrLc ) + return TFileType::FILETYPE_TEMPORARY; + if ( "compressed" == fileTypeStrLc ) + return TFileType::FILETYPE_COMPRESSED; + if ( "other" == fileTypeStrLc ) + return TFileType::FILETYPE_OTHER; + if ( "unknown" == fileTypeStrLc ) + return TFileType::FILETYPE_UNKNOWN; + + return TFileType::FILETYPE_UNKNOWN; +} + +/*-------------------------------------------------------------------------*/ + +bool +FileTypeConfig::LoadConfig( const CORE::CDataNode& cfg ) +{GUCEF_TRACE; + + CORE::CDataNode::TConstDataNodeSet fileTypeNodes = cfg.FindChildrenOfType( "FileType", true, false ); + CORE::CDataNode::TConstDataNodeSet::const_iterator i = fileTypeNodes.begin(); + while ( i != fileTypeNodes.end() ) + { + const CORE::CDataNode& fileTypeNode = *(*i); + + CORE::CString fileTypeStr = fileTypeNode.GetAttributeValueOrChildValueByName( "type" ).AsString(); + CORE::CString::StringSet fileExts = fileTypeNode.GetAttributeValueOrChildValueByName( "extensions" ).AsString().ParseUniqueElements( ',', false ); + CORE::CString sortFolderName = fileTypeNode.GetAttributeValueOrChildValueByName( "sortFolderName" ).AsString(); + + TFileType fileType = FileTypeConfig::GetFileTypeForString( fileTypeStr ); + if ( !sortFolderName.IsNULLOrEmpty() ) + { + m_typeToSortFolderMap[ fileType ] = sortFolderName; + + CORE::CString::StringSet::const_iterator j = fileExts.begin(); + while ( j != fileExts.end() ) + { + const CORE::CString& fileExt = (*j); + m_fileExtToTypeMap[ fileExt.Lowercase() ] = fileType; + ++j; + } + } + ++i; + } + + return !m_typeToSortFolderMap.empty() && !m_fileExtToTypeMap.empty(); +} + +/*-------------------------------------------------------------------------*/ + +TFileType +FileTypeConfig::GetFileTypeForFileExtension( const CORE::CString& fileExt ) const +{GUCEF_TRACE; + + TStringToFileTypeMap::const_iterator i = m_fileExtToTypeMap.find( fileExt.Lowercase() ); + if ( i != m_fileExtToTypeMap.end() ) + return (*i).second; + return TFileType::FILETYPE_UNKNOWN; +} + +/*-------------------------------------------------------------------------*/ + +const CORE::CString& +FileTypeConfig::GetSortRootFolderForFileType( TFileType fileType ) const +{GUCEF_TRACE; + + TFileTypeToStringMap::const_iterator i = m_typeToSortFolderMap.find( fileType ); + if ( i != m_typeToSortFolderMap.end() ) + return (*i).second; + return CORE::CString::Empty; +} + +/*-------------------------------------------------------------------------*/ + +const CORE::CString& +FileTypeConfig::GetSortRootFolderForFileExtension( const CORE::CString& fileExt ) const +{GUCEF_TRACE; + + return GetSortRootFolderForFileType( GetFileTypeForFileExtension( fileExt ) ); +} + +/*-------------------------------------------------------------------------*/ + +const CORE::CString FileSorterConfig::ClassTypeName = "FileSorterConfig"; + +/*-------------------------------------------------------------------------*/ + +FileSorterConfig::FileSorterConfig( void ) + : CORE::CGloballyConfigurable() + , vfsInboxPath() + , vfsSortSourceRootPath() + , vfsSortedTargetRootPath() + , useDateTimeFolderStructure( true ) + , dirStructureUtcOffsetInMins( 0 ) // default keeps filesystem structure in UTC + , yearFolderDecoration( "-== {year} ==-" ) + , useMonthFolder( false ) + , monthFolderDecoration( "-== {month}. {monthName} ==-" ) + , useDayFolder( true ) + , dayFolderDecoration( "{month}.{day}.{year}" ) +{GUCEF_TRACE; + +} + +/*-------------------------------------------------------------------------*/ + +FileSorterConfig::~FileSorterConfig() +{GUCEF_TRACE; +} + +/*-------------------------------------------------------------------------*/ + +bool +FileSorterConfig::SaveConfig( CORE::CDataNode& cfg ) const +{GUCEF_TRACE; + + return false; +} + +/*-------------------------------------------------------------------------*/ + +bool +FileSorterConfig::LoadConfig( const CORE::CDataNode& globalConfig ) +{GUCEF_TRACE; + + bool totalSuccess = true; + + const CORE::CDataNode* cfg = globalConfig.Find( "FileSorterConfig" ); + if ( GUCEF_NULL == cfg ) + return false; + + vfsInboxPath = cfg->GetAttributeValueOrChildValueByName( "vfsInboxPath", vfsInboxPath ).AsString( vfsInboxPath, true ); + vfsSortSourceRootPath = cfg->GetAttributeValueOrChildValueByName( "vfsSortSourceRootPath", vfsSortSourceRootPath ).AsString( vfsSortSourceRootPath, true ); + vfsSortedTargetRootPath = cfg->GetAttributeValueOrChildValueByName( "vfsSortedTargetRootPath", vfsSortedTargetRootPath ).AsString( vfsSortedTargetRootPath, true ); + useDateTimeFolderStructure = cfg->GetAttributeValueOrChildValueByName( "useDateTimeFolderStructure", useDateTimeFolderStructure ).AsBool( useDateTimeFolderStructure, true ); + dirStructureUtcOffsetInMins = cfg->GetAttributeValueOrChildValueByName( "dirStructureUtcOffsetInMins", dirStructureUtcOffsetInMins ).AsInt16( dirStructureUtcOffsetInMins, true ); + yearFolderDecoration = cfg->GetAttributeValueOrChildValueByName( "yearFolderDecoration", yearFolderDecoration ).AsString( yearFolderDecoration, true ); + useMonthFolder = cfg->GetAttributeValueOrChildValueByName( "useMonthFolder", useMonthFolder ).AsBool( useMonthFolder, true ); + monthFolderDecoration = cfg->GetAttributeValueOrChildValueByName( "monthFolderDecoration", monthFolderDecoration ).AsString( monthFolderDecoration, true ); + useDayFolder = cfg->GetAttributeValueOrChildValueByName( "useDayFolder", useDayFolder ).AsBool( useDayFolder, true ); + dayFolderDecoration = cfg->GetAttributeValueOrChildValueByName( "dayFolderDecoration", dayFolderDecoration ).AsString( dayFolderDecoration, true ); + + const CORE::CDataNode* fileTypeConfigNode = cfg->FindChild( "FileTypeConfig" ); + if ( GUCEF_NULL != fileTypeConfigNode ) + { + totalSuccess = fileTypeConfig.LoadConfig( *fileTypeConfigNode ) && totalSuccess; + } + + return totalSuccess; +} + +/*-------------------------------------------------------------------------*/ + +const CORE::CString& +FileSorterConfig::GetClassTypeName( void ) const +{GUCEF_TRACE; + + return ClassTypeName; +} + +/*-------------------------------------------------------------------------*/ + +bool +FileSorter::SortFile( const CORE::CString& currentVfsFilePath ) +{GUCEF_TRACE; + + VFS::CVFS& vfs = VFS::CVfsGlobal::Instance()->GetVfs(); + + CORE::CString filename = CORE::ExtractFilename( currentVfsFilePath ); + CORE::CString fileExt = CORE::ExtractFileExtention( currentVfsFilePath ); + TFileType fileType = m_appConfig.fileTypeConfig.GetFileTypeForFileExtension( fileExt ); + const CORE::CString& typeSortRootFolder = m_appConfig.fileTypeConfig.GetSortRootFolderForFileType( fileType ); + + CORE::CString targetVfsPath = m_appConfig.vfsSortedTargetRootPath + "/" + typeSortRootFolder; + + if ( m_appConfig.useDateTimeFolderStructure ) + { + CORE::CResourceMetaData fileMetaData; + if ( vfs.GetFileMetaData( currentVfsFilePath, fileMetaData ) ) + { + CORE::CDateTime earliestUtcFileDt; + if ( !fileMetaData.GetEarliestUtcDt( earliestUtcFileDt ) ) + { + GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "FileSorter: Failed to get earliest date time for : " + currentVfsFilePath ); + return false; + } + + CORE::CDateTime sortPathDt = earliestUtcFileDt; + sortPathDt.AddMinutes( m_appConfig.dirStructureUtcOffsetInMins ); // this applies a timezone conversion + + CORE::CString sortPathYearStr = m_appConfig.yearFolderDecoration.ReplaceSubstr( "{year}", CORE::ToString( sortPathDt.GetYear() ) ); + + targetVfsPath += "/" + sortPathYearStr; + + if ( m_appConfig.useMonthFolder ) + { + CORE::CString sortPathMonthStr = m_appConfig.monthFolderDecoration.ReplaceSubstr( "{month}", CORE::ToString( sortPathDt.GetMonth() ) ); + sortPathMonthStr = sortPathMonthStr.ReplaceSubstr( "{monthName}", CORE::ToString( sortPathDt.GetMonthName() ) ); + + targetVfsPath += "/" + sortPathMonthStr; + } + + if ( m_appConfig.useDayFolder ) + { + CORE::CString sortPathDayStr = m_appConfig.dayFolderDecoration.ReplaceSubstr( "{day}", CORE::ToString( sortPathDt.GetDay() ) ); + sortPathDayStr = sortPathDayStr.ReplaceSubstr( "{year}", CORE::ToString( sortPathDt.GetYear() ) ); + sortPathDayStr = sortPathDayStr.ReplaceSubstr( "{month}", CORE::ToString( sortPathDt.GetMonth() ) ); + sortPathDayStr = sortPathDayStr.ReplaceSubstr( "{monthName}", CORE::ToString( sortPathDt.GetMonthName() ) ); + + targetVfsPath += "/" + sortPathDayStr; + } + } + else + { + GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "FileSorter: Failed to get file meta data for : " + currentVfsFilePath ); + return false; + } + } + + targetVfsPath += "/" + filename; + + if ( vfs.FileExists( targetVfsPath ) ) + { + GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "FileSorter: File already exists at target location \"" + targetVfsPath + "\". Will add suffix to compensate" ); + + CORE::CString targetVfsPathWithoutExt = CORE::StripFileExtention( targetVfsPath ); + + bool foundAlternate = false; + for ( CORE::UInt32 i=2; i<1000; ++i ) + { + CORE::CString testTargetVfsPath = targetVfsPathWithoutExt + "_" + CORE::ToString( i ) + "." + fileExt; + if ( !vfs.FileExists( testTargetVfsPath ) ) + { + targetVfsPath = testTargetVfsPath; + foundAlternate = true; + break; + } + } + + if ( !foundAlternate ) + { + GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "FileSorter: Failed to find alternate target location for file \"" + targetVfsPath + "\"" ); + return false; + } + } + + if ( vfs.MoveFile( currentVfsFilePath, targetVfsPath, false ) ) // for safety we NEVER overwrite + { + GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "FileSorter: Successfully moved file from \"" + currentVfsFilePath + "\" to \"" + targetVfsPath + "\"" ); + return true; + } + + GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "FileSorter: Failed to move file from \"" + currentVfsFilePath + "\" to \"" + targetVfsPath + "\"" ); + return false; +} + +/*-------------------------------------------------------------------------*/ + +bool +FileSorter::SortFilesInVfsPath( const CORE::CString& vfsRootPath ) +{GUCEF_TRACE; + + bool totalSuccess = true; + if ( vfsRootPath.IsNULLOrEmpty() ) + return true; + + VFS::CVFS& vfs = VFS::CVfsGlobal::Instance()->GetVfs(); + + CORE::CString::StringVector filesToSort; + if ( vfs.GetFileList( filesToSort, vfsRootPath, true, true, CORE::CString::Empty ) ) + { + CORE::CString::StringVector::const_iterator i = filesToSort.begin(); + while ( i != filesToSort.end() ) + { + const CORE::CString& fileToSort = (*i); + totalSuccess = SortFile( fileToSort ) && totalSuccess; + ++i; + } + } + + return totalSuccess; +} + +/*-------------------------------------------------------------------------*/ + +bool +FileSorter::SortInitialRootPaths( void ) +{GUCEF_TRACE; + + return SortFilesInVfsPath( m_appConfig.vfsInboxPath ) && SortFilesInVfsPath( m_appConfig.vfsSortSourceRootPath ); +} + +/*-------------------------------------------------------------------------*/ + +void +FileSorter::OnAppStarted( CORE::CNotifier* notifier , + const CORE::CEvent& eventId , + CORE::CICloneable* eventData ) +{GUCEF_TRACE; + + VFS::CVFS& vfs = VFS::CVfsGlobal::Instance()->GetVfs(); + if ( vfs.IsInitialized() ) + SortInitialRootPaths(); +} + +/*-------------------------------------------------------------------------*/ + +void +FileSorter::OnVfsInitializationCompleted( CORE::CNotifier* notifier , + const CORE::CEvent& eventId , + CORE::CICloneable* eventData ) +{GUCEF_TRACE; + + SortInitialRootPaths(); +} + +/*-------------------------------------------------------------------------*/ + +void +FileSorter::RegisterEventHandlers( void ) +{GUCEF_TRACE; + + CORE::CGUCEFApplication& app = CORE::CCoreGlobal::Instance()->GetApplication(); + + TEventCallback callback( this, &FileSorter::OnAppStarted ); + SubscribeTo( &app , + CORE::CGUCEFApplication::FirstCycleEvent , + callback ); + + VFS::CVFS& vfs = VFS::CVfsGlobal::Instance()->GetVfs(); + TEventCallback callback2( this, &FileSorter::OnVfsInitializationCompleted ); + SubscribeTo( &vfs , + VFS::CVFS::VfsInitializationCompletedEvent , + callback2 ); + +} + +/*-------------------------------------------------------------------------*/ + +FileSorter::FileSorter( void ) + : CORE::CTSGNotifier() + , m_httpServer() + , m_httpRouter() + , m_taskManagementRsc() + , m_globalConfig() + , m_appArgs() + , m_appConfig() +{GUCEF_TRACE; + + RegisterEventHandlers(); +} + +/*-------------------------------------------------------------------------*/ + +FileSorter::~FileSorter() +{GUCEF_TRACE; + + m_httpServer.Close(); + SignalUpcomingDestruction(); +} + +/*-------------------------------------------------------------------------*/ + +bool +FileSorter::Start( void ) +{GUCEF_TRACE; + + bool totalSuccess = true; + + if ( m_httpServer.Listen() ) + { + GUCEF_LOG( CORE::LOGLEVEL_IMPORTANT, "FileSorter: Opened REST API on port " + CORE::UInt16ToString( m_httpServer.GetPort() ) ); + return totalSuccess; + } + + GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "FileSorter: Failed to open REST API on port " + CORE::UInt16ToString( m_httpServer.GetPort() ) ); + return false; + +} + +/*-------------------------------------------------------------------------*/ + +bool +FileSorter::LoadConfig( const CORE::CValueList& appArgs , + const CORE::CDataNode& globalConfig ) +{GUCEF_TRACE; + + m_httpServer.SetPort( CORE::StringToUInt16( CORE::ResolveVars( appArgs.GetValueAlways( "RestApiPort", "10000" ) ) ) ); + m_httpRouter.SetResourceMapping( "/info", RestApiFileSorterInfoResource::THTTPServerResourcePtr( new RestApiFileSorterInfoResource( this ) ) ); + m_httpRouter.SetResourceMapping( "/config/appargs", RestApiFileSorterInfoResource::THTTPServerResourcePtr( new RestApiFileSorterConfigResource( this, true ) ) ); + m_httpRouter.SetResourceMapping( "/config", RestApiFileSorterInfoResource::THTTPServerResourcePtr( new RestApiFileSorterConfigResource( this, false ) ) ); + m_httpRouter.SetResourceMapping( appArgs.GetValueAlways( "RestBasicHealthUri", "/health/basic" ), RestApiFileSorterInfoResource::THTTPServerResourcePtr( new WEB::CDummyHTTPServerResource() ) ); + + if ( !m_taskManagementRsc.ConnectHttpRouting( m_httpRouter ) ) + { + GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "FileSorter: Failed to set up task management API" ); + } + + m_httpServer.GetRouterController()->AddRouterMapping( &m_httpRouter, "", "" ); + + m_appArgs = appArgs; + m_globalConfig.Copy( globalConfig ); + + return m_appConfig.LoadConfig( globalConfig ); +} + +/*-------------------------------------------------------------------------*/ + +const FileSorterConfig& +FileSorter::GetAppConfig( void ) const +{ + return m_appConfig; +} + +/*-------------------------------------------------------------------------*/ + +const CORE::CDataNode& +FileSorter::GetGlobalConfig( void ) const +{ + return m_globalConfig; +} + +/*-------------------------------------------------------------------------*/ diff --git a/tools/FileSorter/src/main.cpp b/tools/FileSorter/src/main.cpp new file mode 100644 index 000000000..7e0639143 --- /dev/null +++ b/tools/FileSorter/src/main.cpp @@ -0,0 +1,331 @@ +/* + * FileSorter: service which sorts files + * + * Copyright (C) 1998 - 2024. Dinand Vanvelzen + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*-------------------------------------------------------------------------// +// // +// INCLUDES // +// // +//-------------------------------------------------------------------------*/ + +#ifndef GUCEF_CORE_CCOREGLOBAL_H +#include "gucefCORE_CCoreGlobal.h" +#define GUCEF_CORE_CCOREGLOBAL_H +#endif /* GUCEF_CORE_CCOREGLOBAL_H ? */ + +#ifndef GUCEF_CORE_CGUCEFAPPLICATION_H +#include "CGUCEFApplication.h" +#define GUCEF_CORE_CGUCEFAPPLICATION_H +#endif /* GUCEF_CORE_CGUCEFAPPLICATION_H ? */ + +#ifndef GUCEF_CORE_LOGGING_H +#include "gucefCORE_Logging.h" +#define GUCEF_CORE_LOGGING_H +#endif /* GUCEF_CORE_LOGGING_H ? */ + +#ifndef GUCEF_CORE_DVCPPOSWRAP_H +#include "DVCPPOSWRAP.h" +#define GUCEF_CORE_DVCPPOSWRAP_H +#endif /* GUCEF_CORE_DVCPPOSWRAP_H ? */ + +#ifndef GUCEF_CORE_DVCPPFILEUTILS_H +#include "dvcppfileutils.h" +#define GUCEF_CORE_DVCPPFILEUTILS_H +#endif /* GUCEF_CORE_DVCPPFILEUTILS_H ? */ + +#ifndef GUCEF_CORE_CROLLINGFILEACCESS_H +#include "gucefCORE_CRollingFileAccess.h" +#define GUCEF_CORE_CROLLINGFILEACCESS_H +#endif /* GUCEF_CORE_CROLLINGFILEACCESS_H ? */ + +#ifndef GUCEF_CORE_CONFIGSTORE_H +#include "CConfigStore.h" +#define GUCEF_CORE_CONFIGSTORE_H +#endif /* GUCEF_CORE_CONFIGSTORE_H ? */ + +#ifndef GUCEF_CORE_CPLATFORMNATIVECONSOLEWINDOW_H +#include "gucefCORE_CPlatformNativeConsoleWindow.h" +#define GUCEF_CORE_CPLATFORMNATIVECONSOLEWINDOW_H +#endif /* GUCEF_CORE_CPLATFORMNATIVECONSOLEWINDOW_H ? */ + +#ifndef GUCEF_CORE_CGLOBALCONFIGVALUELIST_H +#include "gucefCORE_CGlobalConfigValueList.h" +#define GUCEF_CORE_CGLOBALCONFIGVALUELIST_H +#endif /* GUCEF_CORE_CGLOBALCONFIGVALUELIST_H ? */ + +#ifndef GUCEF_CORE_CTIMER_H +#include "CTimer.h" +#define GUCEF_CORE_CTIMER_H +#endif /* GUCEF_CORE_CTIMER_H ? */ + +#ifndef GUCEF_COMCORE_CUDPSOCKET_H +#include "CUDPSocket.h" +#define GUCEF_COMCORE_CUDPSOCKET_H +#endif /* GUCEF_COMCORE_CUDPSOCKET_H ? */ + +#ifndef GUCEF_COMCORE_CTCPSERVERSOCKET_H +#include "CTCPServerSocket.h" +#define GUCEF_COMCORE_CTCPSERVERSOCKET_H +#endif /* GUCEF_COMCORE_CTCPSERVERSOCKET_H ? */ + +#ifndef GUCEF_COMCORE_CCOMCOREGLOBAL_H +#include "gucefCOMCORE_CComCoreGlobal.h" +#define GUCEF_COMCORE_CCOMCOREGLOBAL_H +#endif /* GUCEF_COMCORE_CCOMCOREGLOBAL_H ? */ + +#ifndef GUCEF_COM_CCOMGLOBAL_H +#include "gucefCOM_CComGlobal.h" +#define GUCEF_COM_CCOMGLOBAL_H +#endif /* GUCEF_COM_CCOMGLOBAL_H ? */ + +#ifndef GUCEF_VFS_CVFSGLOBAL_H +#include "gucefVFS_CVfsGlobal.h" +#define GUCEF_VFS_CVFSGLOBAL_H +#endif /* GUCEF_VFS_CVFSGLOBAL_H ? */ + +#ifndef GUCEF_WEB_CWEBGLOBAL_H +#include "gucefWEB_CWebGlobal.h" +#define GUCEF_WEB_CWEBGLOBAL_H +#endif /* GUCEF_WEB_CWEBGLOBAL_H ? */ + +#include "FileSorter.h" + +/*-------------------------------------------------------------------------// +// // +// NAMESPACE // +// // +//-------------------------------------------------------------------------*/ + +using namespace GUCEF; + +/*-------------------------------------------------------------------------// +// // +// IMPLEMENTATION // +// // +//-------------------------------------------------------------------------*/ + +CORE::CString +LookForConfigFile( const CORE::CString& configFile ) +{GUCEF_TRACE; + + GUCEF_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "Checking for config file @ " + configFile ); + if ( !CORE::FileExists( configFile ) ) + { + CORE::CString configFilePath = CORE::CombinePath( "$CURWORKDIR$", configFile ); + configFilePath = CORE::RelativePath( configFilePath ); + + GUCEF_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "Checking for config file @ " + configFilePath ); + if ( !CORE::FileExists( configFilePath ) ) + { + configFilePath = CORE::CombinePath( "$MODULEDIR$", configFile ); + configFilePath = CORE::RelativePath( configFilePath ); + + GUCEF_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "Checking for config file @ " + configFilePath ); + if ( !FileExists( configFilePath ) ) + { + configFilePath = CORE::CombinePath( "$TEMPDIR$", configFile ); + configFilePath = CORE::RelativePath( configFilePath ); + + GUCEF_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "Checking for config file @ " + configFilePath ); + if ( !FileExists( configFilePath ) ) + { + return CORE::CString::Empty; + } + } + } + + return configFilePath; + } + + return configFile; +} + +/*-------------------------------------------------------------------------*/ + +bool +LoadConfig( const CORE::CString& bootstrapConfigPath , + const CORE::CString& configPath , + CORE::CValueList& keyValueList , + CORE::CDataNode* loadedConfig = GUCEF_NULL ) +{GUCEF_TRACE; + + #ifdef GUCEF_DEBUG_MODE + const CORE::CString bootstrapConfigFile = "FileSorter_bootstrap_d.ini"; + const CORE::CString configFile = "FileSorter_d.ini"; + #else + const CORE::CString bootstrapConfigFile = "FileSorter_bootstrap.ini"; + const CORE::CString configFile = "FileSorter.ini"; + #endif + + CORE::CConfigStore& configStore = CORE::CCoreGlobal::Instance()->GetConfigStore(); + + CORE::CString bootstrapConfigFilePath = LookForConfigFile( bootstrapConfigFile ); + CORE::CString configFilePath = LookForConfigFile( configFile ); + + if ( !bootstrapConfigFilePath.IsNULLOrEmpty() ) + { + GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "Located bootstrap config file @ " + bootstrapConfigFilePath ); + configStore.SetBootstrapConfigFile( bootstrapConfigFilePath ); + } + if ( !configFilePath.IsNULLOrEmpty() ) + { + GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "Located config file @ " + configFilePath ); + configStore.SetConfigFile( configFilePath ); + } + if ( bootstrapConfigFilePath.IsNULLOrEmpty() && configFilePath.IsNULLOrEmpty() ) + { + GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "Unable to locate any config file, will rely on params only" ); + } + + CORE::CGlobalConfigValueList globalCfg; + globalCfg.SetConfigNamespace( "Main/AppArgs" ); + globalCfg.SetAllowDuplicates( false ); + globalCfg.SetAllowMultipleValues( true ); + + bool loadSuccess = configStore.LoadConfig( loadedConfig ); + + keyValueList = globalCfg; + return loadSuccess; +} + +/*-------------------------------------------------------------------------*/ + +void +ParseParams( const int argc , + char* argv[] , + CORE::CValueList& keyValueList ) +{GUCEF_TRACE; + + GUCEF::CORE::CString argString; + if ( argc > 0 ) + { + argString = *argv; + + // Combine the argument strings back into a single string because we don't want to use + // a space as the seperator + for ( int i=1; iGetApplication().Stop(); +} + +/*-------------------------------------------------------------------------*/ + +/* + * Application entry point + */ +//GUCEF_OSMAIN_BEGIN +GUCEF_OSSERVICEMAIN_BEGIN( "FileSorter" ) +{GUCEF_TRACE; + + GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "This service was compiled on: " __DATE__ " @ " __TIME__ ); + + CORE::CCoreGlobal::Instance(); + COMCORE::CComCoreGlobal::Instance(); + COM::CComGlobal::Instance(); + VFS::CVfsGlobal::Instance(); + WEB::CWebGlobal::Instance(); + + // Check for config param first + CORE::CValueList keyValueList; + ParseParams( argc, argv, keyValueList ); + CORE::CString bootstrapConfigPathParam = keyValueList.GetValueAlways( "BootstrapConfigPath" ); + CORE::CString configPathParam = keyValueList.GetValueAlways( "ConfigPath" ); + keyValueList.Clear(); + + // Load settings from a config file (if any) and then override with params (if any) + CORE::CDataNode* globalConfig = new CORE::CDataNode(); + if ( !LoadConfig( bootstrapConfigPathParam, configPathParam, keyValueList, globalConfig ) ) + { + GUCEF_ERROR_LOG( CORE::LOGLEVEL_CRITICAL, "Failed to load global config. Exiting" ); + ::GUCEF::CORE::CCoreGlobal::Instance()->GetApplication().Stop( true ); + return -1; + } + ParseParams( argc, argv, keyValueList ); + + CORE::CString outputDir = CORE::RelativePath( keyValueList.GetValueAlways( "outputDir" ) ); + if ( outputDir.IsNULLOrEmpty() ) + { + outputDir = CORE::RelativePath( "$CURWORKDIR$" ); + } + CORE::CreateDirs( outputDir ); + + CORE::CString logFilename = CORE::CombinePath( outputDir, "FileSorter_log.txt" ); + + keyValueList.Set( "logfile", logFilename ); + + CORE::CRollingFileAccess logFileAccess( logFilename, "w" ); + logFileAccess.SetMaxRolloverFilesBeforeDeletion( 10 ); + CORE::CStdLogger logger( logFileAccess ); + CORE::CCoreGlobal::Instance()->GetLogManager().AddLogger( &logger ); + + CORE::CPlatformNativeConsoleLogger console; + if ( GUCEF_APP_TYPE == GUCEF_APP_TYPE_CONSOLE ) + CORE::CCoreGlobal::Instance()->GetLogManager().AddLogger( console.GetLogger() ); + + CORE::Int32 minLogLevel = CORE::LOGLEVEL_BELOW_NORMAL; + CORE::CString valueStr = keyValueList.GetValueAlways( "MinimalLogLevel" ); + if ( !valueStr.IsNULLOrEmpty() ) + { + minLogLevel = CORE::StringToInt32( valueStr ); + CORE::CCoreGlobal::Instance()->GetLogManager().SetMinLogLevel( minLogLevel ); + } + + CORE::CCoreGlobal::Instance()->GetLogManager().FlushBootstrapLogEntriesToLogs(); + GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "Flushed to log @ " + logFilename ); + + GUCEF_OSMAIN_SIGNAL_HANDLER( GucefAppSignalHandler ); + + FileSorter fileSorter; + if ( !fileSorter.LoadConfig( keyValueList, *globalConfig ) ) + { + delete globalConfig; + GUCEF_ERROR_LOG( CORE::LOGLEVEL_CRITICAL, "FileSorter: Exiting because LoadConfig failed" ); + return -1; + } + delete globalConfig; + + if ( !fileSorter.Start() ) + { + GUCEF_ERROR_LOG( CORE::LOGLEVEL_CRITICAL, "FileSorter: Failed to Start()" ); + return -2; + } + + CORE::CGUCEFApplication& app = CORE::CCoreGlobal::Instance()->GetApplication(); + app.GetPulseGenerator()->RequestPulseInterval( 10 ); + int returnValue = app.main( argc, argv, true ); + GUCEF_LOG( CORE::LOGLEVEL_IMPORTANT, "FileSorter: Exited main. Return value = " + CORE::ToString( returnValue ) ); + CORE::CCoreGlobal::Instance()->GetLogManager().FlushLogs(); + return returnValue; +} +GUCEF_OSMAIN_END + +/*---------------------------------------------------------------------------*/ diff --git a/tools/ProcessMetrics/src/main.cpp b/tools/ProcessMetrics/src/main.cpp index 4bc4665e6..8dee98138 100644 --- a/tools/ProcessMetrics/src/main.cpp +++ b/tools/ProcessMetrics/src/main.cpp @@ -291,47 +291,6 @@ GUCEF_OSSERVICEMAIN_BEGIN( "ProcessMetrics" ) GUCEF_OSMAIN_SIGNAL_HANDLER( GucefAppSignalHandler ); - - - - - -CORE::CDStoreCodecRegistry::TDStoreCodecPtr ymlCodec; -if ( CORE::CCoreGlobal::Instance()->GetDStoreCodecRegistry().TryLookup( "yaml", ymlCodec, false ) ) -{ - CORE::CString testfile = CORE::ResolveVars( "$MODULEDIR$\\example.yaml" ); - - CORE::CDataNode doc; - if ( ymlCodec->BuildDataTree( &doc, testfile ) ) - { - CORE::CDStoreCodecRegistry::TDStoreCodecPtr jsonCodec; - if ( CORE::CCoreGlobal::Instance()->GetDStoreCodecRegistry().TryLookup( "json", jsonCodec, false ) ) - { - CORE::CString testOutfile = CORE::ResolveVars( "$MODULEDIR$\\example.json" ); - jsonCodec->StoreDataTree( &doc, testOutfile ); - } - } -} - - - - - - - - - - - - - - - - - - - - ProcessMetrics processMetrics; if ( !processMetrics.LoadConfig( keyValueList, *globalConfig ) ) {