Skip to content

Commit

Permalink
New service, initial version: FileSorter
Browse files Browse the repository at this point in the history
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
  • Loading branch information
LiberatorUSA committed Jul 7, 2024
1 parent 7a85e6d commit eff5b7c
Show file tree
Hide file tree
Showing 37 changed files with 2,816 additions and 45 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/GUCEF_exe_FileSorter.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions platform/gucefCORE/include/gucefCORE_CDate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions platform/gucefCORE/include/gucefCORE_CDateTime.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
7 changes: 7 additions & 0 deletions platform/gucefCORE/include/gucefCORE_CIDate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 //
Expand All @@ -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;
};

Expand Down
3 changes: 3 additions & 0 deletions platform/gucefCORE/include/gucefCORE_CResourceMetaData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

/*-------------------------------------------------------------------------//
Expand Down
14 changes: 14 additions & 0 deletions platform/gucefCORE/src/gucefCORE_CDate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
36 changes: 36 additions & 0 deletions platform/gucefCORE/src/gucefCORE_CDateTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 //
Expand Down
71 changes: 71 additions & 0 deletions platform/gucefCORE/src/gucefCORE_CResourceMetaData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 //
Expand Down
6 changes: 2 additions & 4 deletions platform/gucefVFS/src/gucefVFS_CFileSystemArchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand All @@ -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 ,
Expand Down Expand Up @@ -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 ,
Expand Down
1 change: 1 addition & 0 deletions premake4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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" )
Expand Down
3 changes: 3 additions & 0 deletions projects/Android/targets/GUCEF/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading

0 comments on commit eff5b7c

Please sign in to comment.