Skip to content
Snippets Groups Projects
Commit de90ea04 authored by Alderico Gallo's avatar Alderico Gallo
Browse files

Added find and findrec subcommands

parent 95cad423
No related branches found
No related tags found
No related merge requests found
Pipeline #304 passed
......@@ -4,7 +4,7 @@ include(android-toolchain.cmake)
project(AnForAAndroidToolbox)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -ffunction-sections -fdata-sections")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -ffunction-sections -fdata-sections")
#set(CMAKE_LDFLAGS "${CMAKE_LDFLAGS} -Wl,--gc-sections")
......
# https://stackoverflow.com/a/67729248
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(CMAKE_CXX_STANDARD 20)
if(DEFINED ENV{NDK_HOME})
set(CMAKE_TOOLCHAIN_DIRECTORY "$ENV{NDK_HOME}/build/cmake")
......
#!/bin/sh
export NDK_VERSION="24.0.8215888" #"21.4.7075529"
export NDK_VERSION="25.1.8937393" #"21.4.7075529"
export ANDROID_HOME="${HOME}/Android/Sdk"
./build.sh
......@@ -2,6 +2,7 @@
#include <sys/time.h>
#include <cstring>
#include <vector>
#include <filesystem>
std::vector<std::string> *string_split(const std::string &s, const std::string &del = " ")
{
......@@ -74,6 +75,28 @@ int subcommand_time(int i, char *arguments[])
return -1;
}
int print_dir_recursive(char *arguments[], bool recursive)
{
auto path = std::string(arguments[0]);
//TODO remove code duplication
if (recursive)
{
for (std::filesystem::recursive_directory_iterator i(path), end; i != end; ++i)
if (is_directory(i->path()))
std::cout << i->path().generic_string() << "/\n";
else
std::cout << i->path().generic_string() << "\n";
} else {
for (std::filesystem::directory_iterator i(path), end; i != end; ++i)
if (is_directory(i->path()))
std::cout << i->path().generic_string() << "/\n";
else
std::cout << i->path().generic_string() << "\n";
}
return 0;
}
int main(int argc, char *argv[])
{
if (argc > 1)
......@@ -82,6 +105,12 @@ int main(int argc, char *argv[])
if (subtool == "time")
{
return subcommand_time(argc - 2, &argv[2]);
} else if (subtool == "find")
{
return print_dir_recursive(&argv[2], false);
} else if (subtool == "findrec")
{
return print_dir_recursive(&argv[2], true);
} else {
std::cout << "Unknown command" << std::endl;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment