Browse Source

Quality of code improvements - got rid of all warnings;

main v0.2.2
Unbewohnte 3 years ago
parent
commit
902a579c8d
  1. 18
      build/CMakeLists.txt
  2. 5
      src/broom.cpp
  3. 3
      src/broom.hpp
  4. 4
      src/entry.cpp
  5. 1
      src/entry.hpp
  6. 6
      src/main.cpp

18
build/CMakeLists.txt

@ -5,16 +5,20 @@ project(broom)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_EXE_LINKER_FLAGS "-static")
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE) IF(MSVC)
set(THREADS_PREFER_PTHREAD_FLAG TRUE) # to be made, probably...
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_EXE_LINKER_FLAGS "-static")
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -Wall -Werror -O2") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -O2")
endif()
set(EXECUTABLE_OUTPUT_PATH ../bin) set(EXECUTABLE_OUTPUT_PATH ../bin)

5
src/broom.cpp

@ -24,6 +24,7 @@ along with broom. If not, see <https://www.gnu.org/licenses/>.
#include <chrono> #include <chrono>
#include <stdexcept> #include <stdexcept>
#include <future> #include <future>
#include <string>
#include "entry.hpp" #include "entry.hpp"
#include "broom.hpp" #include "broom.hpp"
@ -161,14 +162,14 @@ void Broom::create_scan_results_list(const std::map<std::string, std::vector<ent
auto now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); auto now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
outfile << ">> Broom scan results file from " << std::ctime(&now) << std::endl << std::endl << std::endl; outfile << ">> Broom scan results file from " << std::ctime(&now) << std::endl << std::endl << std::endl;
for (const auto record : grouped_duplicates) { for (const auto& record : grouped_duplicates) {
if (record.first == "") { if (record.first == "") {
outfile << "[EMPTY FILES]" << std::endl; outfile << "[EMPTY FILES]" << std::endl;
} else { } else {
outfile << "[DUPLICATE GROUP]" << std::endl; outfile << "[DUPLICATE GROUP]" << std::endl;
} }
for (const auto duplicate_entry : record.second) { for (const auto& duplicate_entry : record.second) {
outfile << duplicate_entry.path << std::endl; outfile << duplicate_entry.path << std::endl;
} }

3
src/broom.hpp

@ -23,6 +23,9 @@ along with broom. If not, see <https://www.gnu.org/licenses/>.
#include <cstdint> #include <cstdint>
#include <vector> #include <vector>
#include <map> #include <map>
#include <string>
#include "entry.hpp"
namespace broom { namespace broom {

4
src/entry.cpp

@ -21,7 +21,7 @@ along with broom. If not, see <https://www.gnu.org/licenses/>.
#include <iostream> #include <iostream>
#include <cerrno> #include <cerrno>
#include <cstring> #include <string>
namespace entry { namespace entry {
@ -45,7 +45,7 @@ void Entry::get_pieces() {
entry_file.open(path); entry_file.open(path);
if (!entry_file.is_open()) { if (!entry_file.is_open()) {
throw std::ifstream::failure("Could not open \"" + path.string() + "\"; reason: " + std::string(std::strerror(errno)) + "\n"); throw std::ifstream::failure("Could not open \"" + path.string() + "\"");
} }
char pieces_buffer[PIECE_SIZE * PIECES_AMOUNT]; char pieces_buffer[PIECE_SIZE * PIECES_AMOUNT];

1
src/entry.hpp

@ -24,6 +24,7 @@ along with broom. If not, see <https://www.gnu.org/licenses/>.
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
#include <string>
#include "group.hpp" #include "group.hpp"

6
src/main.cpp

@ -28,7 +28,7 @@ along with broom. If not, see <https://www.gnu.org/licenses/>.
#include "broom.hpp" #include "broom.hpp"
// Broom version number // Broom version number
#define VERSION "v0.2.1" #define VERSION "v0.2.2"
void print_help() { void print_help() {
std::cout std::cout
@ -79,7 +79,7 @@ int main(int argc, char* argv[]) {
}; };
// process command line arguments // process command line arguments
for (unsigned int i = 1; i < argc; i++) { for (unsigned int i = 1; i < (unsigned int) argc; i++) {
// flags -> command -> directory // flags -> command -> directory
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
@ -170,7 +170,7 @@ int main(int argc, char* argv[]) {
// now only files with a non-unique size and contents are being tracked // now only files with a non-unique size and contents are being tracked
// are they REALLY duplicates ? // are they REALLY duplicates ?
// better to leave the REALL cleanup for the user, saving these entries in a file, than doing a blind and possibly destructive purge // better to leave the REALL cleanup for the user, saving these entries in a file, than doing a blind and possibly destructive purge
broom.create_scan_results_list(grouped_duplicates ); broom.create_scan_results_list(grouped_duplicates);
std::cout << "[INFO] Created scan results file" << std::endl; std::cout << "[INFO] Created scan results file" << std::endl;
} catch(const std::exception& e) { } catch(const std::exception& e) {

Loading…
Cancel
Save