Init
This commit is contained in:
commit
da51040bde
9 changed files with 238 additions and 0 deletions
1
.clang-format
Normal file
1
.clang-format
Normal file
|
@ -0,0 +1 @@
|
|||
BasedOnStyle: Chromium
|
16
.drone.yml
Normal file
16
.drone.yml
Normal file
|
@ -0,0 +1,16 @@
|
|||
kind: pipeline
|
||||
type: docker
|
||||
name: default
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: arminfriedl/xwim-build
|
||||
commands:
|
||||
- meson build
|
||||
- ninja -C build
|
||||
- build/src/xwim ../compile-commands.json
|
||||
|
||||
trigger:
|
||||
event:
|
||||
exclude:
|
||||
- tag
|
121
.gitignore
vendored
Normal file
121
.gitignore
vendored
Normal file
|
@ -0,0 +1,121 @@
|
|||
.clangd/
|
||||
build/
|
||||
compile_commands.json
|
||||
|
||||
# Created by https://www.gitignore.io/api/vim,c++,emacs,ninja
|
||||
# Edit at https://www.gitignore.io/?templates=vim,c++,emacs,ninja
|
||||
|
||||
### C++ ###
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
### Emacs ###
|
||||
# -*- mode: gitignore; -*-
|
||||
*~
|
||||
\#*\#
|
||||
/.emacs.desktop
|
||||
/.emacs.desktop.lock
|
||||
*.elc
|
||||
auto-save-list
|
||||
tramp
|
||||
.\#*
|
||||
|
||||
# Org-mode
|
||||
.org-id-locations
|
||||
*_archive
|
||||
|
||||
# flymake-mode
|
||||
*_flymake.*
|
||||
|
||||
# eshell files
|
||||
/eshell/history
|
||||
/eshell/lastdir
|
||||
|
||||
# elpa packages
|
||||
/elpa/
|
||||
|
||||
# reftex files
|
||||
*.rel
|
||||
|
||||
# AUCTeX auto folder
|
||||
/auto/
|
||||
|
||||
# cask packages
|
||||
.cask/
|
||||
dist/
|
||||
|
||||
# Flycheck
|
||||
flycheck_*.el
|
||||
|
||||
# server auth directory
|
||||
/server/
|
||||
|
||||
# projectiles files
|
||||
.projectile
|
||||
|
||||
# directory configuration
|
||||
.dir-locals.el
|
||||
|
||||
# network security
|
||||
/network-security.data
|
||||
|
||||
|
||||
### Ninja ###
|
||||
.ninja_deps
|
||||
.ninja_log
|
||||
|
||||
### Vim ###
|
||||
# Swap
|
||||
[._]*.s[a-v][a-z]
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-rt-v][a-z]
|
||||
[._]ss[a-gi-z]
|
||||
[._]sw[a-p]
|
||||
|
||||
# Session
|
||||
Session.vim
|
||||
Sessionx.vim
|
||||
|
||||
# Temporary
|
||||
.netrwhist
|
||||
|
||||
# Auto-generated tag files
|
||||
tags
|
||||
|
||||
# Persistent undo
|
||||
[._]*.un~
|
||||
|
||||
# Coc configuration directory
|
||||
.vim
|
||||
|
||||
# End of https://www.gitignore.io/api/vim,c++,emacs,ninja
|
2
meson.build
Normal file
2
meson.build
Normal file
|
@ -0,0 +1,2 @@
|
|||
project('xwim', 'cpp', default_options : ['cpp_std=c++17'])
|
||||
subdir('src')
|
26
src/archive.cpp
Normal file
26
src/archive.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include "archive.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
|
||||
#include "spec.hpp"
|
||||
|
||||
namespace xwim {
|
||||
Archive::Archive(std::string path) : path{std::filesystem::path(path)} {}
|
||||
Archive::Archive(std::filesystem::path&& path) : path{path} {}
|
||||
|
||||
ArchiveSpec Archive::check() {
|
||||
return ArchiveSpec{.is_root_dir = true,
|
||||
.is_root_dir_filename = true,
|
||||
.has_subarchive = false};
|
||||
}
|
||||
|
||||
void Archive::extract(ExtractSpec extract_spec) {
|
||||
std::cout << "Make dir:" << extract_spec.make_dir
|
||||
<< "Dirname: " << extract_spec.dirname
|
||||
<< "Archname: " << this->path
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
} // namespace xwim
|
25
src/archive.hpp
Normal file
25
src/archive.hpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef ARCHIVE_H
|
||||
#define ARCHIVE_H
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
#include "spec.hpp"
|
||||
|
||||
namespace xwim {
|
||||
|
||||
class Archive {
|
||||
private:
|
||||
std::filesystem::path path;
|
||||
|
||||
public:
|
||||
explicit Archive(std::string path);
|
||||
explicit Archive(std::filesystem::path&& path);
|
||||
|
||||
ArchiveSpec check();
|
||||
void extract(ExtractSpec normalize_spec);
|
||||
};
|
||||
|
||||
} // namespace xwim
|
||||
|
||||
#endif
|
20
src/main.cpp
Normal file
20
src/main.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
#include "archive.hpp"
|
||||
#include "spec.hpp"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
std::string filename {argv[1]};
|
||||
xwim::Archive archive {filename};
|
||||
|
||||
xwim::ArchiveSpec asp = archive.check();
|
||||
|
||||
std::cout << "Has subarch: " << asp.has_subarchive
|
||||
<< "Is root: " << asp.is_root_dir
|
||||
<< "Is root dir filename: " << asp.is_root_dir_filename
|
||||
<< std::endl;
|
||||
|
||||
archive.extract(xwim::ExtractSpec {.make_dir=true, .dirname="Test"});
|
||||
}
|
9
src/meson.build
Normal file
9
src/meson.build
Normal file
|
@ -0,0 +1,9 @@
|
|||
src = ['main.cpp', 'archive.cpp']
|
||||
inc = ['archive.hpp',
|
||||
'spec.hpp']
|
||||
|
||||
libs = [dependency('libarchive', required: true),
|
||||
dependency('fmt', required: true),
|
||||
dependency('spdlog', required: true)]
|
||||
|
||||
executable('xwim', src, inc, dependencies: libs)
|
18
src/spec.hpp
Normal file
18
src/spec.hpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef SPEC_H
|
||||
#define SPEC_H
|
||||
|
||||
#include <filesystem>
|
||||
namespace xwim {
|
||||
struct ArchiveSpec {
|
||||
bool is_root_dir;
|
||||
bool is_root_dir_filename;
|
||||
bool has_subarchive;
|
||||
};
|
||||
|
||||
struct ExtractSpec {
|
||||
bool make_dir;
|
||||
std::filesystem::path dirname;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue