Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

JustWhit3/cppfetch

Repository files navigation

Logo

v0.1 license C++20
code size repo size total lines

Table of contents

Introduction

cppfetch is a cross-platform (Linux/Windows/MacOS) and thread-safe library for efficiently download files from the web.

The library has been tested with gcc and clang compilers.

To download a single file:

#include <cppfetch/core.hpp>

int main() {
    cppfetch::cppfetch downloader;
    downloader.download_single_file("https://example/url/to/file");
}

To download more files in parallel:

#include <cppfetch/core.hpp>
int main() {
    cppfetch::cppfetch downloader;
    downloader.add_file("https://example/url/to/file_1");
    downloader.add_file("https://example/url/to/file_2");
    downloader.download_all();
}

You can select the number of threads to use in order to download in parallel:

void set_n_threads(10);

Default is the number of available threads of your system.

For an overview of the available features and options see the documentation at the Doxygen page.

Architecture support

Operating systems

  • Linux
    • Ubuntu (tested)
    • WSL (tested)
  • Windows
    • Windows 10 or higher (not tested)
  • MacOS (not tested)

Compilers

  • gcc: v. 10/11/12/13
  • clang: v. 11/12/13/14/15/16/17
  • MSVC: not directly tested, but should work

Install and use

Install

1) Download one of the releases of the repository.

2) Unzip and enter the downloaded repository directory.

3) Install and compile the app and its dependencies:

cmake -B build
sudo cmake --build build --target install

⚠️ sudo is not required on Windows.

Mandatory prerequisites:

  • C++20 standard
  • g++ compiler (library developed on Ubuntu v22.04.1 with g++ v11.4.0)
  • CMake (at least v3.15)
  • Curl
  • OpenMP

To install every prerequisite on ubuntu: sudo apt install libcurl4 libcurl4-openssl-dev libomp-dev

Debug mode and tests

Debug mode is used from developers to test the app. To build the app in debug mode:

cmake -B build -DCMAKE_BUILD_TYPE=Debug
sudo cmake --build build

This will automatically compile unit tests and source code with debug tools.

Prerequisites for debug mode:

To install every prerequisite on ubuntu: sudo apt install libgtest-dev libgmock-dev cppcheck

To run all the unit tests:

./build/test/unit_tests/cppfetch_unit_tests

To run IWYU checks:

./test/IWYU.sh

To run profiling tests:

./test/all_tests.sh

Examples

To compile examples:

cmake -B build
sudo cmake --build build

To run single file download example:

./build/examples/cppfetch_example_single

To run multiple file download example:

./build/examples/cppfetch_example_multiple

Todo

  • Add progress bars in download
  • Add automatic decompression of file if needed
  • Add performance monitoring

Credits


Gianluca Bianco

Stargazers over time

Stargazers over time

About

A library for downloading files from the web, powered by OpenMP and libcurl.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •