TkN 2.1
Toolkit for Nuclei
tksystem.h
1/********************************************************************************
2 * Copyright (c) : Université de Lyon 1, CNRS/IN2P3, UMR5822, *
3 * IP2I, F-69622 Villeurbanne Cedex, France *
4 * Normandie Université, ENSICAEN, UNICAEN, CNRS/IN2P3, *
5 * LPC Caen, F-14000 Caen, France *
6 * Contibutor(s) : *
7 * Jérémie Dudouet jeremie.dudouet@cnrs.fr [2020] *
8 * Diego Gruyer diego.gruyer@cnrs.fr [2020] *
9 * *
10 * This software is governed by the CeCILL-B license under French law and *
11 * abiding by the rules of distribution of free software. You can use, *
12 * modify and/ or redistribute the software under the terms of the *
13 * CeCILL-B license as circulated by CEA, CNRS and INRIA at the following *
14 * URL \"http://www.cecill.info\". *
15 * *
16 * As a counterpart to the access to the source code and rights to copy, *
17 * modify and redistribute granted by the license, users are provided *
18 * only with a limited warranty and the software's author, the holder of *
19 * the economic rights, and the successive licensors have only limited *
20 * liability. *
21 * *
22 * In this respect, the user's attention is drawn to the risks associated *
23 * with loading, using, modifying and/or developing or reproducing the *
24 * software by the user in light of its specific status of free software, *
25 * that may mean that it is complicated to manipulate, and that also *
26 * therefore means that it is reserved for developers and experienced *
27 * professionals having in-depth computer knowledge. Users are therefore *
28 * encouraged to load and test the software's suitability as regards *
29 * their requirements in conditions enabling the security of their *
30 * systems and/or data to be ensured and, more generally, to use and *
31 * operate it in the same conditions as regards security. *
32 * *
33 * The fact that you are presently reading this means that you have had *
34 * knowledge of the CeCILL-B license and that you accept its terms. *
35 ********************************************************************************/
36
37#ifndef tksystem_H
38#define tksystem_H
39
40#include "tkn_config.h"
41
42#ifdef HAS_ROOT
43#include "TClass.h"
44#endif
45
46#include "tkstring.h"
47
48namespace tkn {
49
51
52
53protected:
54 static tksystem *g_tksystem;
55
56public:
58 virtual ~tksystem() = default;
59
61 static tksystem *the_tksystem();
62
63 int getdir (tkstring _dir, std::vector<tkstring> &_files);
64 void list_files(const tkstring &_dir, const tkstring &_pattern);
65 std::vector<tkstring> get_list_of_files(const tkstring &_dir, const tkstring &_pattern="*");
66
67 bool exists(tkstring _file_name);
68
69 int move(const tkstring &_from, const tkstring &_to);
70
71 int remove_dir(const tkstring &_dirname, bool _force = false);
72 int remove_file(const tkstring &_filename, bool _force = false);
73 int make_dir(const tkstring &_dirname, bool _recursive = true);
74
75 int unzip_file(const tkstring &_filename, tkstring _outputdir="");
76
77 int ls_dir(const tkstring &_dirname, tkstring _option="-l");
78
79 int download_file(const tkstring &_filename, const tkstring &_outputdir="", bool _replace_existing = false, bool _use_filename=false);
80
82
83#ifdef HAS_ROOT
85 ClassDef(tksystem,0);
86#endif
87};
88}
89
90#define gsystem (tkn::tksystem::the_tksystem())
91
92#endif
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more....
Definition: tkstring.h:54
Interface to the system (tested on linux and mac os)
Definition: tksystem.h:50
int make_dir(const tkstring &_dirname, bool _recursive=true)
Definition: tksystem.cpp:151
bool exists(tkstring _file_name)
Definition: tksystem.cpp:90
int unzip_file(const tkstring &_filename, tkstring _outputdir="")
Definition: tksystem.cpp:162
int remove_file(const tkstring &_filename, bool _force=false)
Definition: tksystem.cpp:145
std::vector< tkstring > get_list_of_files(const tkstring &_dir, const tkstring &_pattern="*")
Definition: tksystem.cpp:127
static tksystem * the_tksystem()
db_manager is a singleton
Definition: tksystem.cpp:59
int remove_dir(const tkstring &_dirname, bool _force=false)
Definition: tksystem.cpp:139
int ls_dir(const tkstring &_dirname, tkstring _option="-l")
Definition: tksystem.cpp:168
int getdir(tkstring _dir, std::vector< tkstring > &_files)
Definition: tksystem.cpp:68
int move(const tkstring &_from, const tkstring &_to)
Definition: tksystem.cpp:157
void list_files(const tkstring &_dir, const tkstring &_pattern)
Definition: tksystem.cpp:119
int download_file(const tkstring &_filename, const tkstring &_outputdir="", bool _replace_existing=false, bool _use_filename=false)
Definition: tksystem.cpp:173
virtual ~tksystem()=default
tkstring get_system_command_output(tkstring command)
Definition: tksystem.cpp:187
Definition: tklog.cpp:39