diff --git a/src/fs_reader.cpp b/src/fs_reader.cpp new file mode 100644 index 0000000..a8683d5 --- /dev/null +++ b/src/fs_reader.cpp @@ -0,0 +1,33 @@ +#include +#include +#include +#include +namespace fs = std::filesystem; + +// from the provided path, find all files and folders +// This is done by finding all the files and folders in the starting dir +// If a dir was found, then go into it, then find all files and folders in there +// Rinse and Repeat + +// Avoid recursion if possible +std::vector find_all_files(std::string filesystem_path) { + for (const auto & entry : fs::directory_iterator(filesystem_path)) { + std::cout << entry.path() << "\n"; + } + return std::vector(0) = {}; +} + +std::vector find_all_folders(std::string filesystem_path) { + return std::vector(0) = {}; +} + +std::vector find_all_files_and_folders(std::string filesystem_path) { + std::vector files = find_all_files(filesystem_path); + std::vector folders = find_all_folders(filesystem_path); + std::vector files_and_folders = {}; + files_and_folders.reserve(files.size() + folders.size()); + files_and_folders.insert( files_and_folders.end(), files.begin(), files.end() ); + files_and_folders.insert( files_and_folders.end(), folders.begin(), folders.end() ); + + return std::vector(0) = {}; +} diff --git a/src/fs_reader.h b/src/fs_reader.h new file mode 100644 index 0000000..d7af628 --- /dev/null +++ b/src/fs_reader.h @@ -0,0 +1,6 @@ +#include +#include + +std::vector find_all_files(std::string filesystem_path); +std::vector find_all_folders(std::string filesystem_path); +std::vector find_all_files_and_folders(std::string filesystem_path); \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..0bc97a5 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,7 @@ +#include +#include "fs_reader.h" + +int main(int argc, char *argv[]) { + (void)find_all_files_and_folders(argv[1]); + return 0; +} \ No newline at end of file diff --git a/src/tests.cpp b/src/tests.cpp new file mode 100644 index 0000000..b762aa7 --- /dev/null +++ b/src/tests.cpp @@ -0,0 +1,41 @@ +// This file contains all Tests + +#include +#include +#include +#include +#include +#include + +// Here I define all Error Codes +#define not_implemented_error 255 + +int test_cmdline_input_parsing() { + char *argv[] = { + (char*)"--help" + }; + int argc = sizeof(argv)/sizeof(argv[0]); + + return parse_cmdline_arguments(argc, argv);; +} + +// This will run all the tests +int main(void) { + int (*p[1]) () = { + test_cmdline_input_parsing + }; + size_t array_size = sizeof(p)/sizeof(p[0]); + + for (size_t index = 0; index < array_size; index++) { + int status_code; + status_code = p[index](); + + std::cout << "test " + std::to_string(index) + ": "; + switch (status_code) { + case 0: std::cout << "passed\0"; + case 1: std::cout << "failed\0"; + case 255: std::cout << "not yet implemented\0"; + } + } + return 0; +} \ No newline at end of file