diff --git a/src/analyze.cpp b/src/analyze.cpp index 9fe2516..9c61e61 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -126,7 +126,10 @@ namespace i18n_check // load file content into analyzers for (const auto& file : filesToAnalyze) { - callback(++currentFileIndex, filesToAnalyze.size(), file); + if (!callback(++currentFileIndex, filesToAnalyze.size(), file)) + { + return; + } const file_review_type fileType = [&file]() { diff --git a/src/analyze.h b/src/analyze.h index 7c9e3b1..fe64dd5 100644 --- a/src/analyze.h +++ b/src/analyze.h @@ -27,7 +27,7 @@ namespace i18n_check { /// @brief Progress callback for analyze(). - using analyze_callback = std::function; + using analyze_callback = std::function; /// @private std::pair read_utf16_file(const std::wstring& file_name); @@ -45,7 +45,8 @@ namespace i18n_check @param[out] filesThatContainUTF8Signature UTF-8 files that contain a Windows UTF-8 file signature. @param callback Callback function to display the progress. - Takes the current file index, overall file count, and the name of the current file.*/ + Takes the current file index, overall file count, and the name of the current file. + Returning @c indicates that the user cancelled the analysis.*/ void analyze(const std::vector& filesToAnalyze, i18n_check::cpp_i18n_review& cpp, i18n_check::rc_file_review& rc, i18n_check::po_file_review& po, std::vector& filesThatShouldBeConvertedToUTF8, diff --git a/src/main.cpp b/src/main.cpp index b866f5f..003aa10 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -379,11 +379,12 @@ int main(int argc, char* argv[]) filesToAnalyze, cpp, rc, po, filesThatShouldBeConvertedToUTF8, filesThatContainUTF8Signature, readBoolOption("quiet", false) ? - [](const size_t, const size_t, const std::wstring&) {} : + [](const size_t, const size_t, const std::wstring&) { return true; } : [](const size_t currentFileIndex, const size_t fileCount, const std::wstring& file) { std::wcout << L"Examining " << currentFileIndex << L" of " << fileCount << L" files (" << std::filesystem::path(file).filename() << L")\n"; + return true; }); const std::wstringstream report =