18 changed files with 375 additions and 218 deletions
-
3Projects/la_mojo/la_mojo.vpj
-
125Projects/la_mojo/makefile
-
110lib/App/common/SQLite_dataBinder.cpp
-
11lib/App/common/SQLite_dataBinder.h
-
6lib/App/common/dataBinder.h
-
78lib/App/common/dataBinder_ReportAux.cpp
-
20lib/App/common/dataBinder_ReportAux.h
-
24lib/App/common/dataBinder_structures.h
-
50lib/App/common/kernelEventFilterTrain.cpp
-
56lib/App/common/kernelEventFilterTrain.h
-
6lib/App/common/kernelModuleEmbedVideo.cpp
-
51lib/App/common/kernelModuleReportBackupper.cpp
-
4lib/App/common/kernelModuleReportBackupper.h
-
2lib/App/mojo/mojoBackend.cpp
-
10lib/App/mojo/mojoKernel.cpp
-
7lib/components/base/basicEvent.h
-
24lib/components/base/basicFunctionality.cpp
-
6lib/components/base/basicFunctionality.h
@ -0,0 +1,78 @@ |
|||
#include "dataBinder_ReportAux.h"
|
|||
|
|||
void fillRDF( uint32_t ts, REPORT_DIRINFO &RDF ){ |
|||
memset( &RDF, 0, sizeof(REPORT_DIRINFO)); |
|||
if ( ts ) { |
|||
time_t tt = ts; |
|||
struct tm * tmp = localtime( &tt ); |
|||
if ( tmp ) { |
|||
sprintf( RDF.DAY, "%02d", tmp->tm_mday); |
|||
sprintf( RDF.MONTH, "%02d", 1+tmp->tm_mon ); |
|||
sprintf( RDF.YEAR, "%04d", 1900+tmp->tm_year ); |
|||
RDF.ts = getTsFromRDF( RDF ); |
|||
}; |
|||
}; |
|||
}; |
|||
|
|||
bool checkRDFDir( CSTR basePath, REPORT_DIRINFO &RDF, bool recreate, uid_t uid, gid_t gid, mode_t mode ){ |
|||
char tBuff[MAX_PATH]; |
|||
sprintf( tBuff, "%s/%s", basePath, RDF.YEAR ); |
|||
// If recreate GID and UID must be supplied!
|
|||
if( recreate ){ |
|||
if( uid == -1 || gid == -1 ){ |
|||
return false; |
|||
}; |
|||
}; |
|||
if( fileExist( tBuff ) == 0 ){ |
|||
if ( recreate ) { |
|||
if (!createAccessibleDir( tBuff, mode, uid, gid )) return false; |
|||
} else return false; |
|||
}; |
|||
sprintf( tBuff, "%s/%s/%s", basePath, RDF.YEAR, RDF.MONTH ); |
|||
if( fileExist( tBuff ) == 0 ){ |
|||
if ( recreate ) { |
|||
if( !createAccessibleDir( tBuff, mode, uid, gid ) ) return false; |
|||
} else return false; |
|||
}; |
|||
sprintf( tBuff, "%s/%s/%s/%s", basePath, RDF.YEAR, RDF.MONTH, RDF.DAY ); |
|||
if( fileExist( tBuff ) == 0 ){ |
|||
if ( recreate ) { |
|||
if( !createAccessibleDir( tBuff, mode, uid, gid ) ) return false; |
|||
} else return false; |
|||
}; |
|||
return true; |
|||
}; |
|||
|
|||
uint32_t getTsFromRDF( REPORT_DIRINFO &RDF ){ |
|||
struct tm ltm; |
|||
memset( <m, 0, sizeof( struct tm )); |
|||
ltm.tm_mday = atoi( RDF.DAY ); |
|||
ltm.tm_mon = atoi( RDF.MONTH ) - 1; |
|||
ltm.tm_year = atoi( RDF.YEAR ) - 1900; |
|||
return (uint32_t) timelocal( <m ); |
|||
}; |
|||
|
|||
bool deleteRDFDir( CSTR Base, REPORT_DIRINFO &RDF ){ |
|||
char tBuff[MAX_PATH]; |
|||
sprintf( tBuff, "%s/%s/%s/%s", Base, RDF.YEAR, RDF.MONTH, RDF.DAY ); |
|||
// No Checking if dir is empty - dir contents all we need to delete!
|
|||
if( fileExist( tBuff ) ){ |
|||
sprintf( tBuff, "rm -f -R \"%s/%s/%s/%s\"", Base, RDF.YEAR, RDF.MONTH, RDF.DAY ); |
|||
system( tBuff ); |
|||
}; |
|||
sprintf( tBuff, "%s/%s/%s", Base, RDF.YEAR, RDF.MONTH ); |
|||
if( fileExist( tBuff ) ){ |
|||
if( dirEmpty( tBuff ) ){ |
|||
sprintf( tBuff, "rm -f -R \"%s/%s/%s\"", Base, RDF.YEAR, RDF.MONTH ); |
|||
system( tBuff ); |
|||
}; |
|||
}; |
|||
sprintf( tBuff, "%s/%s", Base, RDF.YEAR ); |
|||
if( fileExist( tBuff ) ){ |
|||
if( dirEmpty( tBuff ) ){ |
|||
sprintf( tBuff, "rm -f -R \"%s/%s\"", Base, RDF.YEAR ); |
|||
system( tBuff ); |
|||
}; |
|||
}; |
|||
return true; |
|||
}; |
|||
@ -0,0 +1,20 @@ |
|||
#ifndef __DATA_BINDER_REPORT_AUX_HEADER__ |
|||
#define __DATA_BINDER_REPORT_AUX_HEADER__ |
|||
|
|||
#include "dataBinder_structures.h" |
|||
#include "../../components/base/basicFunctionality.h" |
|||
|
|||
typedef struct S_REPORT_DIRINFO{ |
|||
char YEAR[5]; |
|||
char MONTH[3]; |
|||
char DAY[3]; |
|||
time_t ts; |
|||
}REPORT_DIRINFO; |
|||
|
|||
uint32_t getTsFromRDF( REPORT_DIRINFO &RDF ); |
|||
bool checkRDFDir( CSTR basePath, REPORT_DIRINFO &RDF, bool recreate=false, uid_t uid=-1, gid_t gid=-1, mode_t mode=STORAGE_DIR_MODE ); |
|||
bool deleteRDFDir( CSTR Base, REPORT_DIRINFO &RDF ); |
|||
REPORT_DIRINFO * getReportDirInfo( uint32_t id ); |
|||
void fillRDF( uint32_t ts, REPORT_DIRINFO &RDF ); |
|||
|
|||
#endif |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue