diff --git a/joomer-efsw-bsz-monitoring.cpp b/joomer-efsw-bsz-monitoring.cpp index fbd5f42..a025161 100644 --- a/joomer-efsw-bsz-monitoring.cpp +++ b/joomer-efsw-bsz-monitoring.cpp @@ -174,7 +174,8 @@ void do_sync_render(std::string fileToRender) // 2. Setup the output path using a relative path that goes OUTSIDE 'test' dl::bella_sdk::Node pathNode = engine.scene().createNode("outputImagePath"); - pathNode["dir"] = dl::String("."); + pathNode["dir"] = dl::String(directory_path.c_str()); + //pathNode["dir"] = dl::String("."); pathNode["name"] = dl::String("render_result"); pathNode["ext"] = dl::String(".png"); @@ -314,7 +315,10 @@ void flip_image_vertically(unsigned char* data, int width, int height, int chann delete[] temp_row; } -int main( int argc, char** argv ) { +//int main( int argc, char** argv ) { +#include "dl_core/dl_main.inl" +#include "dl_core/dl_args.h" +int DL_main(dl::Args& args) { signal( SIGABRT, sigend ); signal( SIGINT, sigend ); signal( SIGTERM, sigend ); @@ -328,7 +332,9 @@ int main( int argc, char** argv ) { bool useGeneric = false; std::string path; - if ( argc >= 2 ) { + args.add("wd", "watchdir", "", "mode file watch"); + + /*if (argc >= 2) { path = std::string( argv[1] ); if ( efsw::FileSystem::isDirectory( path ) ) { @@ -340,6 +346,15 @@ int main( int argc, char** argv ) { useGeneric = true; } } + }*/ + //std::cout << "args: " << args. << std::endl; + if (args.have("--watchdir")) { + path = args.value("--watchdir").buf(); + std::cout << "Watching path: " << path << std::endl; + if (efsw::FileSystem::isDirectory(path)) { + commonTest = false; + useGeneric = true; // Force generic for testing + } } UpdateListener* ul = new UpdateListener(); @@ -350,6 +365,7 @@ int main( int argc, char** argv ) { fileWatcher.followSymlinks( false ); fileWatcher.allowOutOfScopeLinks( false ); + std::cout << "commonTest: " << commonTest << std::endl; if ( commonTest ) { std::string CurPath( efsw::System::getProcessPath() ); @@ -364,9 +380,10 @@ int main( int argc, char** argv ) { } else { if ( fileWatcher.addWatch( path, ul, true ) > 0 ) { fileWatcher.watch(); - + /// add a watch to the system + handleWatchID(fileWatcher.addWatch(path, ul, true)); std::cout << "Watching directory: " << path.c_str() << std::endl; - + directory_path = path; if ( useGeneric ) { std::cout << "Using generic backend watcher" << std::endl; }