### Install Dependencies for Fedora/RHEL
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/README.md
Installs necessary build dependencies for ai-file-sorter on Fedora or RHEL-based systems. It includes setting up the PATH for Qt6 tools and linking a JSONcpp header file, followed by installing development packages.
```bash
export PATH="/usr/lib64/qt6/libexec:$PATH"
sudo mkdir -p /usr/include/jsoncpp/json
sudo ln -s /usr/include/json/json.h /usr/include/jsoncpp/json/json.h
```
```bash
sudo dnf install -y gcc-c++ cmake git qt6-qtbase-devel qt6-qttools-devel \
libcurl-devel jsoncpp-devel sqlite-devel openssl-devel fmt-devel spdlog-devel
```
--------------------------------
### Install ai-file-sorter System-wide
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/README.md
Installs the compiled ai-file-sorter application system-wide using the Make install target. This typically copies the executable and related files to standard system directories, making the application accessible from anywhere.
```bash
sudo make install
```
--------------------------------
### Example: Adding Nodes and Attributes in C++
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/pugixml/docs/manual.html
A C++ code example demonstrating how to add a new node, a description node with text, a parameter node inserted before the description, and attributes to the parameter node using the pugi::xml_document object.
```cpp
// add node with some name
pugi::xml_node node = doc.append_child("node");
// add description node with text child
pugi::xml_node descr = node.append_child("description");
descr.append_child(pugi::node_pcdata).set_value("Simple node");
// add param node before the description
pugi::xml_node param = node.insert_child_before("param", descr);
// add attributes to param node
param.append_attribute("name") = "version";
param.append_attribute("value") = 1.1;
```
--------------------------------
### Install Project Documentation (CMake)
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/libzip/man/CMakeLists.txt
Installs project documentation files, either as HTML or man pages, based on the build configuration. It specifies source files, installation destinations, and renaming conventions.
```cmake
INSTALL(FILES ${PROJECT_BINARY_DIR}/man/${SOURCE}.3 DESTINATION ${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME} RENAME ${TARGET}.html)
else()
INSTALL(FILES ${PROJECT_BINARY_DIR}/man/${SOURCE}.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3 RENAME ${TARGET}.3)
endif()
endif()
endif()
endforeach()
```
--------------------------------
### Install Dependencies with Homebrew
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/README.md
Installs essential development dependencies for the AI File Sorter project using Homebrew. This includes libraries like Qt, curl, jsoncpp, and build tools like cmake and git. Ensure Homebrew is installed before running this command.
```bash
brew install qt curl jsoncpp sqlite openssl fmt spdlog cmake git pkgconfig libffi
```
--------------------------------
### Install Linux Runtime Prerequisites (Ubuntu 24.04 / Debian 12)
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/README.md
Installs essential runtime libraries for AI File Sorter on Ubuntu 24.04 or Debian 12, including Qt6, networking, database, and math libraries. This command ensures the system has the necessary components for the application to function correctly.
```bash
sudo apt update && sudo apt install -y \
libqt6widgets6 libcurl4 libjsoncpp25 libfmt9 libopenblas0-pthread \
libvulkan1 mesa-vulkan-drivers patchelf
```
--------------------------------
### CMake Project Setup and Options
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/libzip/CMakeLists.txt
Initializes the CMake project, sets the project version, and defines various build options. These options control the inclusion of features like different encryption libraries, compression algorithms, and build targets such as tools, tests, and examples. The configuration also handles compatibility for older CMake versions.
```cmake
cmake_minimum_required(VERSION 3.10)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
if (${CMAKE_VERSION} VERSION_LESS "3.17.0")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake-compat)
endif()
project(libzip
VERSION 1.11.4
LANGUAGES C)
if(NOT libzip_VERSION_PATCH)
set(libzip_VERSION_PATCH 0)
endif()
option(ENABLE_COMMONCRYPTO "Enable use of CommonCrypto" ON)
option(ENABLE_GNUTLS "Enable use of GnuTLS" ON)
option(ENABLE_MBEDTLS "Enable use of mbed TLS" ON)
option(ENABLE_OPENSSL "Enable use of OpenSSL" ON)
option(ENABLE_WINDOWS_CRYPTO "Enable use of Windows cryptography libraries" ON)
option(ENABLE_BZIP2 "Enable use of BZip2" ON)
option(ENABLE_LZMA "Enable use of LZMA" ON)
option(ENABLE_ZSTD "Enable use of Zstandard" ON)
option(ENABLE_FDOPEN "Enable zip_fdopen, which is not allowed in Microsoft CRT secure libraries" ON)
option(BUILD_TOOLS "Build tools in the src directory (zipcmp, zipmerge, ziptool)" ON)
option(BUILD_REGRESS "Build regression tests" ON)
option(BUILD_OSSFUZZ "Build fuzzers for ossfuzz" ON)
option(BUILD_EXAMPLES "Build examples" ON)
option(BUILD_DOC "Build documentation" ON)
include(CheckFunctionExists)
include(CheckIncludeFiles)
include(CheckLibraryExists)
include(CheckSymbolExists)
include(CheckTypeSize)
include(CheckCSourceRuns)
include(CheckCSourceCompiles)
include(CheckStructHasMember)
include(TestBigEndian)
include(GNUInstallDirs)
if(ENABLE_COMMONCRYPTO)
check_include_files(CommonCrypto/CommonCrypto.h COMMONCRYPTO_FOUND)
endif()
if(ENABLE_GNUTLS)
find_package(Nettle 3.0)
find_package(GnuTLS)
endif()
if(ENABLE_MBEDTLS)
find_package(MbedTLS 1.0)
endif()
if(ENABLE_OPENSSL)
find_package(OpenSSL)
endif()
if(WIN32)
if(ENABLE_WINDOWS_CRYPTO)
set(WINDOWS_CRYPTO_FOUND TRUE)
endif()
endif()
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(LIBZIP_DO_INSTALL "Install libzip and the related files" ON)
option(SHARED_LIB_VERSIONNING "Add SO version in .so build" ON)
find_program(MDOCTOOL NAMES mandoc groff)
if (MDOCTOOL)
set(DOCUMENTATION_FORMAT "mdoc" CACHE STRING "Documentation format")
else()
find_program(MANTOOL NAMES nroff)
if (MANTOOL)
set(DOCUMENTATION_FORMAT "man" CACHE STRING "Documentation format")
else()
set(DOCUMENTATION_FORMAT "html" CACHE STRING "Documentation format")
endif()
endif()
include(Dist)
Dist(${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION})
#ADD_CUSTOM_TARGET(uninstall
# COMMAND cat ${PROJECT_BINARY_DIR}/install_manifest.txt | xargs rm
# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
# )
if(BUILD_SHARED_LIBS)
set(HAVE_SHARED TRUE)
else()
set(ZIP_STATIC TRUE)
endif()
```
--------------------------------
### Install Dependencies for Debian/Ubuntu
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/README.md
Installs essential build tools and libraries required for compiling ai-file-sorter on Debian-based systems like Ubuntu. This includes compilers, CMake, Git, Qt6 development files, and various runtime libraries.
```bash
sudo apt update && sudo apt install -y \
build-essential cmake git qt6-base-dev qt6-base-dev-tools qt6-tools-dev-tools \
libcurl4-openssl-dev libjsoncpp-dev libsqlite3-dev libssl-dev libfmt-dev libspdlog-dev \
zlib1g-dev
```
--------------------------------
### Install Linux Runtime Prerequisites (Debian 13)
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/README.md
Installs essential runtime libraries for AI File Sorter on Debian 13 (trixie), including updated versions of Qt6, networking, database, and math libraries. This command ensures the system has the necessary components for the application to function correctly on newer Debian releases.
```bash
sudo apt update && sudo apt install -y \
libqt6widgets6 libcurl4t64 libjsoncpp26 libfmt10 libopenblas0-pthread \
libvulkan1 mesa-vulkan-drivers patchelf
```
--------------------------------
### Install AI File Sorter Debian Package
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/README.md
Installs the AI File Sorter application from a prebuilt Debian package. Using 'apt install' ensures that any missing dependencies are automatically resolved and installed, simplifying the installation process.
```bash
sudo apt install ./aifilesorter_1.0.0_amd64.deb
```
--------------------------------
### Install Dependencies for Arch/Manjaro
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/README.md
Installs the required build tools and libraries for ai-file-sorter on Arch Linux or Manjaro. This command ensures that base development tools, Git, CMake, Qt6, and necessary runtime libraries are present.
```bash
sudo pacman -S --needed base-devel git cmake qt6-base qt6-tools curl jsoncpp sqlite openssl fmt spdlog
```
--------------------------------
### Example: Modifying XML Text Content in C++
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/pugixml/docs/manual.html
A practical C++ example demonstrating the modification of XML text content using `xml_text` objects. It shows how to update a version number and set the content of a newly appended description node.
```cpp
// change project version
project.child("version").text() = 1.2;
// add description element and set the contents
// note that we do not have to explicitly add the node_pcdata child
project.append_child("description").text().set("a test project");
```
--------------------------------
### Install Target Configuration (CMake)
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/libzip/lib/CMakeLists.txt
This CMake snippet defines the installation rules for the 'zip' target if LIBZIP_DO_INSTALL is enabled. It specifies the destination directories for runtime files, archives, and headers during the installation process.
```cmake
if(LIBZIP_DO_INSTALL)
install(TARGETS zip
EXPORT ${PROJECT_NAME}-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
```
--------------------------------
### Install Man Pages and Documentation (CMake)
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/libzip/man/CMakeLists.txt
Configures installation rules for man pages and HTML documentation based on the build type and documentation format. It handles different destination directories for man pages and HTML files, ensuring proper deployment.
```cmake
if(LIBZIP_DO_INSTALL)
if (DOCUMENTATION_FORMAT MATCHES "html")
install(FILES ${PROJECT_BINARY_DIR}/man/${MAN_PAGE} DESTINATION ${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME} RENAME ${SOURCE_FILE})
else()
string(REGEX REPLACE ".*(.)$" "man\\1" SUBDIR ${MAN_PAGE})
install(FILES ${PROJECT_BINARY_DIR}/man/${MAN_PAGE} DESTINATION ${CMAKE_INSTALL_MANDIR}/${SUBDIR})
endif()
endif()
```
--------------------------------
### Configure Qt Environment Variables
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/README.md
Sets environment variables to ensure the build system can locate the installed Qt binaries and pkg-config files. This is crucial for projects that depend on Qt for their build process. Run these commands after installing Qt via Homebrew.
```bash
export PATH="$(brew --prefix)/opt/qt/bin:$PATH"
export PKG_CONFIG_PATH="$(brew --prefix)/lib/pkgconfig:$(brew --prefix)/share/pkgconfig:$PKG_CONFIG_PATH"
```
--------------------------------
### Saving XML with Default Options
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/pugixml/docs/manual.html
Demonstrates saving an XML document to standard output using the default saving options in pugixml. This example shows the typical formatted output with indentation and a default XML declaration.
```cpp
// get a test document
pugi::xml_document doc;
doc.load_string("hey");
// default options; prints
//
//
// hey
//
doc.save(std::cout);
std::cout << std::endl;
```
--------------------------------
### Example XML Document and Tree Representation
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/pugixml/docs/manual.html
This snippet shows a complete XML document example, illustrating various node types including elements, attributes, comments, CDATA sections, and processing instructions. The corresponding tree representation is also referenced.
```xml
some text
some more text
```
--------------------------------
### Compile AI File Sorter Application
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/README.md
Compiles the main AI File Sorter application using `make`. The `-j8` flag controls the number of parallel jobs for faster compilation. An optional `make install` command is provided to install the binary. The default binary location is `app/bin/aifilesorter`.
```bash
cd app
make -j8 # use -jN to control parallelism
sudo make install # optional
```
--------------------------------
### Managing Extra Fields Individually in C with libzip
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/libzip/API-CHANGES.md
Explains the rewrite of extra field handling in libzip, replacing zip_get_file_extra() and zip_set_file_extra(). New functions allow individual management of extra fields by ID or index, including set, get, count, and delete operations.
```c
/* The text lists the new functions but does not provide direct code examples */
/* Example: zip_file_extra_field_set(za, index, id, data, len, flags); */
/* Example: zip_file_extra_field_get(za, index, id, data, len, flags); */
/* Example: zip_file_extra_field_delete_by_id(za, index, id, flags); */
```
--------------------------------
### Configure Project with Qt and vcpkg (Windows)
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/README.md
Configures the project using CMake on Windows, integrating Qt and vcpkg. It sets the VCPKG_ROOT environment variable, specifies the Qt installation path, and uses the vcpkg toolchain file to manage dependencies. Finally, it builds the project in Release configuration.
```powershell
$env:VCPKG_ROOT = "C:\\path\\to\\vcpkg" # example: C:\\dev\\vcpkg
$qt = "C:\\Qt\\6.6.3\\msvc2019_64" # example
cmake -S . -B build -G "Ninja" \
-DCMAKE_PREFIX_PATH=$qt \
-DCMAKE_TOOLCHAIN_FILE=$env:VCPKG_ROOT\\scripts\\buildsystems\\vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=x64-windows
cmake --build build --config Release
```
--------------------------------
### Build Qt6 Application (PowerShell)
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/README.md
Builds the main Qt6 application using a helper PowerShell script. This script also handles deploying runtime DLLs using windeployqt. It requires specifying the vcpkg root directory.
```powershell
# One-time per shell if script execution is blocked:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
app\build_windows.ps1 -Configuration Release -VcpkgRoot C:\dev\vcpkg
```
--------------------------------
### Configure and Install Package Configuration (CMake)
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/libzip/CMakeLists.txt
Configures the main package CMake configuration file and installs it along with other necessary components. This script uses `configure_package_config_file` to process a template (`.in`) file into a final configuration file, which is then installed to the specified destination. It also handles the installation of dependency find modules and export sets.
```cmake
if(LIBZIP_DO_INSTALL)
configure_package_config_file("${PROJECT_NAME}-config.cmake.in" "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libzip)
# Install Find* modules, they are required by libzip-config.cmake to resolve dependencies
install(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindNettle.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Findzstd.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindMbedTLS.cmake
DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake/libzip/modules
)
# Add targets to the build-tree export set
export(TARGETS zip
FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-targets.cmake")
# installation
install(FILES ${PROJECT_BINARY_DIR}/zipconf.h DESTINATION include)
install(FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake ${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
install(EXPORT ${PROJECT_NAME}-targets NAMESPACE libzip:: FILE ${PROJECT_NAME}-targets.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
if(BUILD_TOOLS)
install(EXPORT ${PROJECT_NAME}-bin-targets NAMESPACE libzip:: FILE ${PROJECT_NAME}-bin-targets.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
endif()
endif()
```
--------------------------------
### Install Pugixml Components (CMake)
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/pugixml/CMakeLists.txt
This snippet handles the installation of Pugixml components, including runtime, library, and development files. It conditionally sets component names and installs targets, configuration files, and header files.
```cmake
if(PUGIXML_INSTALL)
if (NOT DEFINED PUGIXML_RUNTIME_COMPONENT)
set(PUGIXML_RUNTIME_COMPONENT Runtime)
endif()
if (NOT DEFINED PUGIXML_LIBRARY_COMPONENT)
set(PUGIXML_LIBRARY_COMPONENT Library)
endif()
if (NOT DEFINED PUGIXML_DEVELOPMENT_COMPONENT)
set(PUGIXML_DEVELOPMENT_COMPONENT Development)
endif()
set(namelink-component)
if (NOT CMAKE_VERSION VERSION_LESS 3.12)
set(namelink-component NAMELINK_COMPONENT ${PUGIXML_DEVELOPMENT_COMPONENT})
endif()
install(TARGETS ${install-targets}
EXPORT pugixml-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${PUGIXML_RUNTIME_COMPONENT}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${PUGIXML_LIBRARY_COMPONENT} ${namelink-component}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${PUGIXML_DEVELOPMENT_COMPONENT}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}${versioned-dir}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime OPTIONAL)
install(EXPORT pugixml-targets
NAMESPACE pugixml::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pugixml COMPONENT ${PUGIXML_DEVELOPMENT_COMPONENT})
install(FILES
"${PROJECT_BINARY_DIR}/pugixml-config-version.cmake"
"${PROJECT_BINARY_DIR}/pugixml-config.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pugixml COMPONENT ${PUGIXML_DEVELOPMENT_COMPONENT})
install(FILES ${PROJECT_BINARY_DIR}/pugixml.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT ${PUGIXML_DEVELOPMENT_COMPONENT})
install(
FILES
"${PROJECT_SOURCE_DIR}/src/pugiconfig.hpp"
"${PROJECT_SOURCE_DIR}/src/pugixml.hpp"
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}${versioned-dir} COMPONENT ${PUGIXML_DEVELOPMENT_COMPONENT})
endif()
```
--------------------------------
### Basic Build Process with CMake
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/libzip/INSTALL.md
Standard commands to build the project using CMake. This involves creating a build directory, configuring the build with CMake, compiling the code, running tests, and installing the project.
```shell
mkdir build
cd build
cmake ..
make
make test
make install
```
--------------------------------
### Example: Selecting Nodes with XPath in C++
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/pugixml/docs/manual.html
Demonstrates selecting multiple nodes based on attributes and conditions, then iterating through the results to print specific attribute values. It also shows selecting a single node based on a text content condition.
```cpp
pugi::xpath_node_set tools = doc.select_nodes("/Profile/Tools/Tool[@AllowRemote='true' and @DeriveCaptionFrom='lastparam']");
std::cout << "Tools:\n";
for (pugi::xpath_node_set::const_iterator it = tools.begin(); it != tools.end(); ++it)
{
pugi::xpath_node node = *it;
std::cout << node.node().attribute("Filename").value() << "\n";
}
pugi::xpath_node build_tool = doc.select_node("//Tool[contains(Description, 'build system')]");
if (build_tool)
std::cout << "Build tool: " << build_tool.node().attribute("Filename").value() << "\n";
```
--------------------------------
### Configure RPATH for Installed Binaries (CMake)
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/libzip/CMakeLists.txt
Sets the RPATH for installed binaries on non-Linux systems to include the library directory. This ensures that the dynamic linker can find shared libraries at runtime. It uses CMake's installation prefix and library directory variables.
```cmake
if(NOT CMAKE_SYSTEM_NAME MATCHES Linux)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()
```
--------------------------------
### Build and Run Tests with CMake (Linux)
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/README.md
Configures, builds, and runs unit tests for the AI File Sorter project on Linux using CMake and Catch2. It enables test building via a CMake flag and utilizes parallel building and testing for faster execution. The `nproc` command is used to determine the number of available processors.
```bash
cmake -S app -B build-tests -DAI_FILE_SORTER_BUILD_TESTS=ON
cmake --build build-tests --target ai_file_sorter_tests --parallel $(nproc)
ctest --test-dir build-tests --output-on-failure -j $(nproc)
```
--------------------------------
### Create Windows Starter Executable
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/app/CMakeLists.txt
This CMake code defines a Windows-specific starter executable named 'StartAiFileSorter'. It links necessary Qt libraries and defines preprocessor macros for Windows development, such as WIN32_LEAN_AND_MEAN and NOMINMAX.
```cmake
if(WIN32)
set(STARTER_TARGET StartAiFileSorter)
add_executable(${STARTER_TARGET} WIN32
"${CMAKE_CURRENT_SOURCE_DIR}/startapp_windows.cpp"
)
target_link_libraries(${STARTER_TARGET} PRIVATE
Qt6::Widgets Qt6::Gui Qt6::Core
)
target_compile_definitions(${STARTER_TARGET} PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
endif()
```
--------------------------------
### Install Project Files with CMake
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/libzip/lib/CMakeLists.txt
Installs project header and library files to their designated system directories. This ensures that the project's components are correctly placed for system-wide access.
```cmake
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES zip.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
```
--------------------------------
### Configure Installation Paths for Pugixml (CMake)
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/pugixml/CMakeLists.txt
This snippet configures the installation directories for Pugixml, handling both absolute and relative paths to ensure a relocatable package. It sets up include and library directories based on CMAKE_INSTALL_INCLUDEDIR and CMAKE_INSTALL_LIBDIR.
```cmake
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
set(PUGIXML_PC_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
else()
set(PUGIXML_PC_INCLUDEDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
endif()
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
set(PUGIXML_PC_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
else()
set(PUGIXML_PC_LIBDIR "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
endif()
configure_file(scripts/pugixml.pc.in pugixml.pc @ONLY)
```
--------------------------------
### Using pugi namespace in C++
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/pugixml/docs/manual.html
Demonstrates how to access pugixml classes and functions by either using explicit namespace qualification or a 'using' directive. This is essential for interacting with the library's components.
```cpp
#include "pugixml.hpp"
// Option 1: Explicit qualification
void process_node_explicit(pugi::xml_node node) {
// ... use node ...
}
// Option 2: Using directive
void process_node_implicit() {
using namespace pugi;
xml_node node;
// ... use node ...
}
// Option 3: Using specific symbols
void process_document() {
using pugi::xml_document;
xml_document doc;
// ... use doc ...
}
```
--------------------------------
### Build llama.cpp Runtime with Optional Backends (Windows)
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/README.md
Builds the llama.cpp runtime on Windows using a PowerShell script. This script supports enabling or disabling CUDA and Vulkan backends, and specifies the vcpkg root directory for dependency management. This build is necessary before configuring the GUI application.
```powershell
pwsh .\app\scripts\build_llama_windows.ps1 [cuda=on|off] [vulkan=on|off] [vcpkgroot=C:\\dev\\vcpkg]
```
--------------------------------
### Enabling Verbose Build Output with Make
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/libzip/INSTALL.md
Instructions on how to obtain verbose output during the 'make' process. This can be helpful for debugging build issues.
```shell
make VERBOSE=1
```
--------------------------------
### Link ZLIB and Set Include Directories (CMake)
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/libzip/lib/CMakeLists.txt
This CMake code links the 'zip' library against ZLIB and configures public include directories for build and installation. It ensures that the necessary headers are available during compilation and when the library is installed.
```cmake
target_link_libraries(zip PRIVATE ZLIB::ZLIB)
target_include_directories(zip
PUBLIC
$
$
$
)
```
--------------------------------
### Build and Run Tests with CMake (macOS)
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/README.md
Configures, builds, and runs unit tests for the AI File Sorter project on macOS using CMake and Catch2. Similar to Linux, it enables test building via a CMake flag and uses parallel execution. It substitutes `$(nproc)` with `$(sysctl -n hw.ncpu)` for determining the number of CPU cores.
```bash
cmake -S app -B build-tests -DAI_FILE_SORTER_BUILD_TESTS=ON
cmake --build build-tests --target ai_file_sorter_tests --parallel $(sysctl -n hw.ncpu)
ctest --test-dir build-tests --output-on-failure -j $(sysctl -n hw.ncpu)
```
--------------------------------
### XML Node Path Navigation and Access
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/pugixml/docs/manual.html
Provides methods to access XML nodes using a path string or to get the root node. It also includes a method to get the offset for debugging purposes. These functions are crucial for navigating and locating specific elements within an XML structure.
```cpp
string_t path(char_t delimiter = '/') const;
xml_node xml_node::first_element_by_path(const char_t* path, char_t delimiter = '/') const;
xml_node root() const;
ptrdiff_t offset_debug() const;
```
--------------------------------
### Build and Run Tests via Script (Windows)
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/README.md
Builds and runs unit tests for the AI File Sorter project on Windows using the `build_windows.ps1` script. This script simplifies the process by allowing the user to specify the build configuration and explicitly enable test building and execution with dedicated flags.
```powershell
app\build_windows.ps1 -Configuration Release -BuildTests -RunTests
```
--------------------------------
### Compile and Run Taxonomy Prototype (Bash)
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/prototypes/constrained_taxonomy/README.md
Demonstrates how to compile and execute the TaxonomyTemplatePrototype.cpp file. It requires C++20 support and takes a file path and a category as command-line arguments.
```bash
cd prototypes/constrained_taxonomy
c++ -std=c++20 TaxonomyTemplatePrototype.cpp -o taxonomy_prototype
./taxonomy_prototype /path/to/file.iso "Operating Systems"
```
--------------------------------
### Miscellaneous Functions
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/pugixml/docs/manual.html
Provides functions for retrieving the document root, handling node paths, and getting node offsets.
```APIDOC
## Miscellaneous Functions
### Description
Provides functions for retrieving the document root, handling node paths, and getting node offsets.
### Functions
#### `xml_node xml_node::root() const`
- **Description**: Returns the root node of the document the node belongs to. Returns a null node if the current node is null.
- **Returns**: The root `xml_node` or a null node.
#### `string_t xml_node::path(char_t delimiter = '/') const`
- **Description**: Returns the path to the node from the document root. The path consists of node names separated by the specified delimiter. Supports '.' and '..' for self and parent respectively.
- **Parameters**:
- `delimiter` (char_t): The delimiter to use for separating node names in the path. Defaults to '/'.
- **Returns**: A string representing the path to the node.
#### `xml_node xml_node::first_element_by_path(const char_t* path, char_t delimiter = '/') const`
- **Description**: Finds the first node that matches the given path. The path can be absolute or relative. If any component of the path is not found, or if the node is null, a null node is returned.
- **Parameters**:
- `path` (const char_t*): The path to search for.
- `delimiter` (char_t): The delimiter used in the path. Defaults to '/'.
- **Returns**: The `xml_node` found at the specified path, or a null node if not found.
#### `ptrdiff_t xml_node::offset_debug() const`
- **Description**: Retrieves the offset of the node from the beginning of the XML buffer. This is available if the node has not been significantly changed since parsing and was parsed from a stream. Returns -1 if the offset is not available.
- **Returns**: The offset in `pugi::char_t` units, or -1 if not available.
```
--------------------------------
### Implement Include Tags with Node Cloning in C++
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/pugixml/docs/manual.html
An example demonstrating how to implement XML include tags using node cloning. This C++ code recursively preprocesses XML, loads included files, and inserts their content into the main document by cloning nodes.
```cpp
bool preprocess(pugi::xml_node node)
{
for (pugi::xml_node child = node.first_child(); child; )
{
if (child.type() == pugi::node_pi && strcmp(child.name(), "include") == 0)
{
pugi::xml_node include = child;
// load new preprocessed document (note: ideally this should handle relative paths)
const char* path = include.value();
pugi::xml_document doc;
if (!load_preprocess(doc, path)) return false;
// insert the comment marker above include directive
node.insert_child_before(pugi::node_comment, include).set_value(path);
// copy the document above the include directive (this retains the original order!)
for (pugi::xml_node ic = doc.first_child(); ic; ic = ic.next_sibling())
{
node.insert_copy_before(ic, include);
}
// remove the include node and move to the next child
child = child.next_sibling();
node.remove_child(include);
}
else
{
if (!preprocess(child)) return false;
child = child.next_sibling();
}
}
return true;
}
bool load_preprocess(pugi::xml_document& doc, const char* path)
{
pugi::xml_parse_result result = doc.load_file(path, pugi::parse_default | pugi::parse_pi); // for
return result ? preprocess(doc) : false;
}
```
--------------------------------
### libzip API Changes - Version 1.10.0
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/libzip/API-CHANGES.md
Details changes introduced in libzip version 1.10.0, specifically the deprecation of zip_source_zip and zip_source_zip_create, and their replacements.
```APIDOC
## Changed in libzip-1.10.0
### Deprecated `zip_source_zip` and `zip_source_zip_create`
These functions have been replaced with `zip_source_zip_file` and `zip_source_zip_file_create`. The implicit handling of the `ZIP_FL_COMPRESSED` flag has been removed; the flag can now be specified explicitly.
To get the compressed data for the whole file:
```c
zip_source_zip_file(za, source_archive, source_index, ZIP_FL_COMPRESSED, 0, -1, NULL)
```
```
--------------------------------
### Build llama.cpp Runtime Variants (PowerShell)
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/README.md
Builds different runtime variants of the llama.cpp library for Windows using a PowerShell script. Supports CPU-only (with OpenBLAS), CUDA, and Vulkan backends. The `vcpkgroot` parameter specifies the vcpkg installation path.
```powershell
# CPU / OpenBLAS only
app\scripts\build_llama_windows.ps1 cuda=off vulkan=off vcpkgroot=C:\dev\vcpkg
# CUDA (requires matching NVIDIA toolkit/driver)
app\scripts\build_llama_windows.ps1 cuda=on vulkan=off vcpkgroot=C:\dev\vcpkg
# Vulkan (requires LunarG Vulkan SDK or vendor Vulkan 1.2+ runtime)
app\scripts\build_llama_windows.ps1 cuda=off vulkan=on vcpkgroot=C:\dev\vcpkg
```
--------------------------------
### Attribute Manipulation API
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/pugixml/docs/manual.html
This section covers the functions and operators available for setting the name and value of XML attributes. It supports various data types for attribute values and provides examples of usage.
```APIDOC
## Setting Attribute Data
All attributes have a name and value, both of which are strings. These can be set using the following functions:
### Functions for Setting Name and Value
- `bool xml_attribute::set_name(const char_t* rhs)`: Sets the attribute name.
- `bool xml_attribute::set_name(const char_t* rhs, size_t sz)`: Sets the attribute name with a specified size.
- `bool xml_attribute::set_name(string_view_t rhs)`: Sets the attribute name using a string view.
- `bool xml_attribute::set_value(const char_t* rhs)`: Sets the attribute value.
- `bool xml_attribute::set_value(const char_t* rhs, size_t size)`: Sets the attribute value with a specified size.
- `bool xml_attribute::set_value(string_view_t rhs)`: Sets the attribute value using a string view.
These functions return `true` on success and `false` if the attribute handle is null or memory is insufficient. The provided string is copied into document-managed memory.
### Functions for Setting Numeric and Boolean Values
In addition to string functions, the following functions handle attributes with numeric and boolean values:
- `bool xml_attribute::set_value(int rhs)`
- `bool xml_attribute::set_value(unsigned int rhs)`
- `bool xml_attribute::set_value(long rhs)`
- `bool xml_attribute::set_value(unsigned long rhs)`
- `bool xml_attribute::set_value(double rhs)`
- `bool xml_attribute::set_value(double rhs, int precision)`
- `bool xml_attribute::set_value(float rhs)`
- `bool xml_attribute::set_value(float rhs, int precision)`
- `bool xml_attribute::set_value(bool rhs)`
- `bool xml_attribute::set_value(long long rhs)`
- `bool xml_attribute::set_value(unsigned long long rhs)`
These functions convert the argument to a string before calling the base `set_value` function. Note that number conversion depends on the C locale.
### Assignment Operators
For convenience, assignment operators are provided, which call the corresponding `set_value` function:
- `xml_attribute& xml_attribute::operator=(const char_t* rhs)`
- `xml_attribute& xml_attribute::operator=(string_view_t rhs)`
- `xml_attribute& xml_attribute::operator=(int rhs)`
- `xml_attribute& xml_attribute::operator=(unsigned int rhs)`
- `xml_attribute& xml_attribute::operator=(long rhs)`
- `xml_attribute& xml_attribute::operator=(unsigned long rhs)`
- `xml_attribute& xml_attribute::operator=(double rhs)`
- `xml_attribute& xml_attribute::operator=(float rhs)`
- `xml_attribute& xml_attribute::operator=(bool rhs)`
- `xml_attribute& xml_attribute::operator=(long long rhs)`
- `xml_attribute& xml_attribute::operator=(unsigned long long rhs)`
These operators ignore the return value of `set_value`, thus ignoring errors.
### Example Usage
```cpp
pugi::xml_attribute attr = node.attribute("id");
// change attribute name/value
std::cout << attr.set_name("key") << ", " << attr.set_value("345");
std::cout << ", new attribute: " << attr.name() << "=" << attr.value() << std::endl;
// we can use numbers or booleans
attr.set_value(1.234);
std::cout << "new attribute value: " << attr.value() << std::endl;
// we can also use assignment operators for more concise code
attr = true;
std::cout << "final attribute value: " << attr.value() << std::endl;
```
```
--------------------------------
### XML Document Loading from Streams and Files
Source: https://github.com/hyperfield/ai-file-sorter/blob/main/external/pugixml/docs/manual.html
Provides methods for loading XML data into an xml_document from various sources, including standard input streams (std::istream, std::wistream), strings, and files. It supports different parsing options and encoding detection for robust loading.
```cpp
xml_parse_result load(std::istream& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
xml_parse_result load(std::wistream& stream, unsigned int options = parse_default);
xml_parse_result load_string(const char_t* contents, unsigned int options = parse_default);
xml_parse_result load_file(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
xml_parse_result load_file(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
```