Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/cxong/tinydir.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCong <congusbongus@gmail.com>2021-11-21 10:20:55 +0300
committerGitHub <noreply@github.com>2021-11-21 10:20:55 +0300
commit98495119dc3ee6065e2601b0c266a5d464a9587d (patch)
tree1308299ddb9328334143b2051dd3d887d8f85018
parent4acafe7916720645bf65e19be8603acfe7acdba1 (diff)
Add more configurations to build matrix, update cpp_sample
-rw-r--r--.github/workflows/cmake.yml24
-rw-r--r--samples/CMakeLists.txt3
-rw-r--r--samples/cpp_sample.cpp27
-rw-r--r--tests/CMakeLists.txt2
4 files changed, 36 insertions, 20 deletions
diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
index a666bf4..100c6c8 100644
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -6,24 +6,20 @@ on:
pull_request:
branches: [ master ]
-env:
- # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
- BUILD_TYPE: Release
-
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
- include:
+ build_type: [Release, Debug]
+ os: [macos-latest, ubuntu-latest]
+ CC: [clang, gcc]
+ gcc_version: [latest, 11]
+ exclude:
- os: macos-latest
- CC: clang
- - os: ubuntu-latest
CC: gcc
+ - CC: clang
gcc_version: 11
- - os: ubuntu-latest
- CC: gcc
- gcc_version: latest
steps:
- uses: actions/checkout@v2
@@ -38,8 +34,8 @@ jobs:
env:
CC: ${{ matrix.CC }}
run: |
- cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} tests
- cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
+ cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON tests
+ cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}}
- name: Test
working-directory: ${{github.workspace}}/build
@@ -50,5 +46,5 @@ jobs:
CC: ${{ matrix.CC }}
run: |
rm -rf ${{github.workspace}}/build
- cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} samples
- cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
+ cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON samples
+ cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}}
diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt
index 24a1b09..4763a67 100644
--- a/samples/CMakeLists.txt
+++ b/samples/CMakeLists.txt
@@ -1,5 +1,4 @@
-cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
-cmake_policy(VERSION 2.6)
+cmake_minimum_required(VERSION 3.0)
project(tinydir)
diff --git a/samples/cpp_sample.cpp b/samples/cpp_sample.cpp
index f8e386a..c93bd2f 100644
--- a/samples/cpp_sample.cpp
+++ b/samples/cpp_sample.cpp
@@ -1,4 +1,5 @@
#include <iostream>
+#include <list>
#include <stdexcept>
#include <string>
@@ -8,7 +9,9 @@ class TinyDir {
public:
TinyDir(const std::string& path);
~TinyDir();
- std::string BaseName() const;
+ std::string baseName() const;
+ std::list<std::string> listDir();
+
private:
tinydir_dir* dir;
};
@@ -22,10 +25,11 @@ TinyDir::TinyDir(const std::string& path) : dir(new tinydir_dir) {
}
TinyDir::~TinyDir() {
+ tinydir_close(dir);
delete dir;
}
-std::string TinyDir::BaseName() const {
+std::string TinyDir::baseName() const {
const std::string path{dir->path};
auto lastSlash = path.find_last_of("/\\");
if (lastSlash == std::string::npos) {
@@ -34,13 +38,30 @@ std::string TinyDir::BaseName() const {
return path.substr(lastSlash + 1);
}
+std::list<std::string> TinyDir::listDir()
+{
+ std::list<std::string> files;
+
+ while (dir->has_next)
+ {
+ tinydir_file file;
+ tinydir_readfile(dir, &file);
+
+ files.push_back(std::string{dir->path} + "/" + file.name);
+
+ tinydir_next(dir);
+ }
+
+ return files;
+}
+
int main(int argc, char* argv[]) {
if (argc != 2) {
std::cerr << "Usage: cpp_sample filename\n";
return 1;
}
TinyDir td{argv[1]};
- std::cout << "Basename is " << td.BaseName() << "\n";
+ std::cout << "Basename is " << td.baseName() << "\n";
return 0;
}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 487c59f..e140d5a 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.0)
project(tinydir_tests C)