moved source files into src
This commit is contained in:
parent
9c539fed11
commit
33efe3686b
33
src/fs_reader.cpp
Normal file
33
src/fs_reader.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
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<std::string> find_all_files(std::string filesystem_path) {
|
||||
for (const auto & entry : fs::directory_iterator(filesystem_path)) {
|
||||
std::cout << entry.path() << "\n";
|
||||
}
|
||||
return std::vector<std::string>(0) = {};
|
||||
}
|
||||
|
||||
std::vector<std::string> find_all_folders(std::string filesystem_path) {
|
||||
return std::vector<std::string>(0) = {};
|
||||
}
|
||||
|
||||
std::vector<std::string> find_all_files_and_folders(std::string filesystem_path) {
|
||||
std::vector<std::string> files = find_all_files(filesystem_path);
|
||||
std::vector<std::string> folders = find_all_folders(filesystem_path);
|
||||
std::vector<std::string> 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<std::string>(0) = {};
|
||||
}
|
6
src/fs_reader.h
Normal file
6
src/fs_reader.h
Normal file
@ -0,0 +1,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
std::vector<std::string> find_all_files(std::string filesystem_path);
|
||||
std::vector<std::string> find_all_folders(std::string filesystem_path);
|
||||
std::vector<std::string> find_all_files_and_folders(std::string filesystem_path);
|
7
src/main.cpp
Normal file
7
src/main.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include <iostream>
|
||||
#include "fs_reader.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
(void)find_all_files_and_folders(argv[1]);
|
||||
return 0;
|
||||
}
|
41
src/tests.cpp
Normal file
41
src/tests.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
// This file contains all Tests
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
// 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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user