CBuild
C++ build system with scripts written in c++
|
Enumerations | |
enum | type { FILE , DIRECTORY , DIR , SYMLINK_FILE , SYMLINK_DIRECTORY , SYMLINK_DIR , HARDLINK } |
Type for element creating. More... | |
Functions | |
int | replace (std::string file, std::string token, std::string data) |
Replace [token] by [data] in [file]. | |
int | set_var (std::string file, std::string var_type, std::string var_name, std::string data) |
Set value of variable with type var_type wth name var_name to data This function loocks for variable like this: <var_type> <var_name> , then it gets all before <var_type> and saves it to variable. Then it gets all after first ; and saves it to variable or if we do define, simply skips this part, (so be careful with including something after define, or after replacing multiline define). Then it reconstruct variable part to <var_type> <var_name> = <date> or #define <var_name> <date> if we do define (var_name == define or #define ). Then it reconstruct line from prefix, variable and postfix and writes it to file. | |
std::string | path_to_file (std::string in) |
Convert path to filename by replacing '\' by '.'. | |
std::vector< std::string > | dir (std::string path, std::string search) |
Search files using provided regex. | |
std::vector< std::string > | dir (std::string path) |
Search files using standard regex (".*\.(cpp|cxx|cc|c)") | |
std::vector< std::string > | dir_rec (std::string path, std::string search) |
Recursively search files using provided regex. | |
std::vector< std::string > | dir_rec (std::string path) |
Recursively search files using standard regex (".*\.(cpp|cxx|cc|c)") | |
bool | remove (std::string path, bool force=false) |
Delete files or directories. | |
bool | copy (std::string start, std::string end) |
Copy files or directories. | |
bool | move (std::string start, std::string end) |
Move files or directories, remove starting files or directories. | |
bool | rename (std::string start, std::string end) |
Rename files or directories,. | |
bool | create (std::vector< std::string > paths, CBuild::fs::type what) |
Create element. | |
bool | exists (std::string path) |
Check if file exists. | |
std::string | normalize_path (std::string path, std::string base_path="") |
Get absolute path to file using relative path and base path. | |
std::string | normalize_relative_path (std::string path, std::string base_path="") |
Get absolute path to file using relative path and base path. | |
std::string | base (std::string file) |
Get base file path (path to dir in what file is) | |
std::string | curr_path () |
Get current working dir of CBuild.run process. | |
std::regex | c_cpp_file (".*\\.(cpp|cxx|cc|c)") |
enum CBuild::fs::type |
Type for element creating.
Definition at line 34 of file filesystem++.hpp.
std::string CBuild::fs::base | ( | std::string | file | ) |
Get base file path (path to dir in what file is)
file | => std::string -> Filepath |
Definition at line 365 of file filesystem++.cpp.
Referenced by CBuild::get_file_data(), and parse_file().
bool CBuild::fs::copy | ( | std::string | start, |
std::string | end ) |
Copy files or directories.
start | => std::string -> path to file or directory |
end | => std::string -> path to file or directory after copy |
Definition at line 178 of file filesystem++.cpp.
Referenced by CBuild::MINGW_GXX< hash >::post_link(), CBuild::MINGW_GXXMT< hash >::post_link(), CBuild::MINGW_GCC< hash >::post_link(), CBuild::MINGW_GCCMT< hash >::post_link(), and CBuild::CBuildDependency::prepare().
bool CBuild::fs::create | ( | std::vector< std::string > | paths, |
CBuild::fs::type | what ) |
Create element.
paths | => std::vector<std::string> -> Path to new element or path to file and then to link for symlinks and hardlinks |
what | => CBuild::fs::type -> What create (custom enum type) |
Definition at line 210 of file filesystem++.cpp.
References DIR, DIRECTORY, FILE, HARDLINK, SYMLINK_DIR, SYMLINK_DIRECTORY, and SYMLINK_FILE.
Referenced by CBuild::Init::call(), CBuild::ccj_out::generate(), CBuild::makefile_out::generate(), CBuild::NetDependency::git_fetch(), CBuild::Toolchain::init(), CBuild::loop(), CBuild::CBuildDependency::prepare(), replace(), set_var(), and CBuild::store_hash().
std::string CBuild::fs::curr_path | ( | ) |
Get current working dir of CBuild.run process.
Definition at line 368 of file filesystem++.cpp.
Referenced by normalize_relative_path().
std::vector< std::string > CBuild::fs::dir | ( | std::string | path | ) |
Search files using standard regex (".*\.(cpp|cxx|cc|c)")
path | => std::string -> Starting path for search |
Definition at line 63 of file filesystem++.cpp.
References c_cpp_file(), CBuild::printf_full(), and CBuild::RED.
std::vector< std::string > CBuild::fs::dir | ( | std::string | path, |
std::string | search ) |
Search files using provided regex.
path | => std::string -> Starting path for search |
search | => std::string -> Search regex |
Definition at line 39 of file filesystem++.cpp.
References CBuild::printf_full(), and CBuild::RED.
Referenced by CBuild::Toolchain::gen_file_list(), CBuild::load_hash(), and CBuild::CBuildDependency::prepare().
std::vector< std::string > CBuild::fs::dir_rec | ( | std::string | path | ) |
Recursively search files using standard regex (".*\.(cpp|cxx|cc|c)")
path | => std::string -> Starting path for search |
Definition at line 109 of file filesystem++.cpp.
References c_cpp_file(), CBuild::printf_full(), and CBuild::RED.
std::vector< std::string > CBuild::fs::dir_rec | ( | std::string | path, |
std::string | search ) |
Recursively search files using provided regex.
path | => std::string -> Starting path for search |
search | => std::string -> Search regex |
Definition at line 85 of file filesystem++.cpp.
References CBuild::printf_full(), and CBuild::RED.
bool CBuild::fs::exists | ( | std::string | path | ) |
Check if file exists.
path | => std::string -> path |
Definition at line 343 of file filesystem++.cpp.
Referenced by CBuild::Init::call(), CBuild::ccj_out::generate(), CBuild::makefile_out::generate(), CBuild::get_file_data(), CBuild::Toolchain::init(), CBuild::loop(), CBuild::CBuildDependency::need_prepare(), parse_file(), read_file_metadata_internal(), and CBuild::read_target_metadata_direct().
bool CBuild::fs::move | ( | std::string | start, |
std::string | end ) |
Move files or directories, remove starting files or directories.
start | => std::string -> path to file or directory |
end | => std::string -> path to file or directory after move |
Definition at line 193 of file filesystem++.cpp.
References remove().
std::string CBuild::fs::normalize_path | ( | std::string | path, |
std::string | base_path = "" ) |
Get absolute path to file using relative path and base path.
path | => std::string -> Relative path to file |
base_path | => std::string -> Base path of this reative path, "" to none |
Definition at line 348 of file filesystem++.cpp.
std::string CBuild::fs::normalize_relative_path | ( | std::string | path, |
std::string | base_path = "" ) |
Get absolute path to file using relative path and base path.
path | => std::string -> Relative path to file |
base_path | => std::string -> Base path of this reative path, "" to none |
Definition at line 356 of file filesystem++.cpp.
References curr_path().
Referenced by CBuild::gcc_hash_impl(), CBuild::Toolchain::gen_file_list(), CBuild::get_file_data(), and parse_file().
std::string CBuild::fs::path_to_file | ( | std::string | in | ) |
bool CBuild::fs::remove | ( | std::string | path, |
bool | force = false ) |
Delete files or directories.
path | => std::string -> path to file or directory |
force | => remove_all in place of remove |
Definition at line 147 of file filesystem++.cpp.
Referenced by CBuild::NetDependency::git_fetch(), move(), replace(), and set_var().
bool CBuild::fs::rename | ( | std::string | start, |
std::string | end ) |
Rename files or directories,.
std::runtime_error | with error message as string |
start | => std::string -> path to file or directory |
end | => std::string -> new name (without path) |
Definition at line 131 of file filesystem++.cpp.
int CBuild::fs::replace | ( | std::string | file, |
std::string | token, | ||
std::string | data ) |
Replace [token] by [data] in [file].
Filebuffer for CBuild ecosystem.
file | => std::string -> Path to file |
token | => std::string -> Token for replacing |
data | => std::string -> Data that replace token |
@license GPL v3.0 or later
Copyright (C) 2022 WolodiaM This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Definition at line 28 of file files.cpp.
References CBUILD_CACHE_DIR, CBUILD_COPY_CACHE_DIR, create(), FILE, move(), path_to_file(), and remove().
int CBuild::fs::set_var | ( | std::string | file, |
std::string | var_type, | ||
std::string | var_name, | ||
std::string | data ) |
Set value of variable with type var_type wth name var_name to data This function loocks for variable like this: <var_type> <var_name>
, then it gets all before <var_type>
and saves it to variable. Then it gets all after first ;
and saves it to variable or if we do define, simply skips this part, (so be careful with including something after define, or after replacing multiline define). Then it reconstruct variable part to <var_type> <var_name> = <date>
or #define <var_name> <date>
if we do define (var_name == define
or #define
). Then it reconstruct line from prefix, variable and postfix and writes it to file.
file | => std::string -> Path to file for replacing |
var_type | => std::string -> Type of variable |
var_name | => std::string -> Name of variable |
data | => std::string -> New value of variable |
Definition at line 63 of file files.cpp.
References CBUILD_CACHE_DIR, CBUILD_COPY_CACHE_DIR, create(), FILE, move(), path_to_file(), and remove().