diff --git a/premake5.lua b/premake5.lua index 514fe39..941c695 100644 --- a/premake5.lua +++ b/premake5.lua @@ -180,7 +180,7 @@ workspace "efsw" kind "ConsoleApp" language "C++" links { "efsw-static-lib" } - files { "src/test/*.cpp" } + files { "src/test/efsw-test.cpp" } includedirs { "include", "src" } conf_links() diff --git a/src/joomer-efsw-file-monitoring.cpp b/src/joomer-efsw-file-monitoring.cpp index 0cc57db..88a58ca 100644 --- a/src/joomer-efsw-file-monitoring.cpp +++ b/src/joomer-efsw-file-monitoring.cpp @@ -49,37 +49,7 @@ class UpdateListener : public efsw::FileWatchListener { ( oldFilename.empty() ? "" : "from file " + oldFilename + " to " ) + filename + ") has event " << getActionName( action ) << std::endl; - - // Check if a file was added (dropped) - /*if (action == efsw::Actions::Add) { - int width, height, channels; - // Reconstruct the full path - std::string fullPath = dir + filename; - - // Add this delay - efsw::System::sleep(500); - - std::cout << "File dropped: " << filename << std::endl; - std::cout << "Full path: " << fullPath << std::endl; - unsigned char* image_data = stbi_load(fullPath.c_str(), &width, &height, &channels, 0); - if (image_data) - { - std::cout << "DEBUG: Image loaded successfully. Flipping..." << std::endl; - flip_image_vertically(image_data, width, height, channels); - // --- Save the flipped image to a new temporary file --- - std::string flipped_filename = "flipped_" + filename; - stbi_write_jpg(flipped_filename.c_str(), width, height, channels, image_data, 100); // Quality 100 - stbi_image_free(image_data); - - STOP = true; - } - else - { - // This will tell you if the path was wrong or the file was locked - std::cout << "DEBUG: stbi_load failed for: " << fullPath << std::endl; - std::cout << "Reason: " << stbi_failure_reason() << std::endl; - } - }*/ + if (action == efsw::Actions::Add || action == efsw::Actions::Modified) { // 1. Ignore the event if it's a file WE created if (filename.find("flipped_") == 0) { @@ -188,7 +158,7 @@ int main( int argc, char** argv ) { handleWatchID( fileWatcher.addWatch( CurPath + "test", ul, true ) ); /// adds another watch after started watching... - efsw::System::sleep( 100 ); + /*efsw::System::sleep( 100 ); efsw::WatchID watchID = handleWatchID( fileWatcher.addWatch( CurPath + "test2", ul, true ) ); @@ -197,7 +167,7 @@ int main( int argc, char** argv ) { if ( watchID > 0 ) { efsw::System::sleep( 1000 ); fileWatcher.removeWatch( watchID ); - } + }*/ } else { if ( fileWatcher.addWatch( path, ul, true ) > 0 ) { fileWatcher.watch();