13 cout <<
"Attempted to open file: " << file_name <<
" ";
14 cout <<
"but a Error ocurred. Check if the file exist." << endl;
23 filein.open(string_path);
25 while(getline(filein,line)){
33 std::ofstream fileout;
35 fileout.open(file_path);
37 for(
auto line : content){
38 fileout << line <<
'\n';
44 vector<string> parents;
45 for(
size_t i = 0; i < file_path.size(); i++){
46 if(file_path[i] ==
'/'){
48 for(
size_t j = 0; j < i; j++){
54 for(
auto folder : parents){
55 const char *cfolder = folder.c_str();
61 ifstream json_file(string_path,std::ifstream::binary);
70 if (FILE *file = fopen(file_path.c_str(),
"r")) {
79 struct stat path_stat;
80 auto path_c_str = path.c_str();
81 stat(path_c_str,&path_stat);
82 return S_ISREG(path_stat.st_mode);
105 if(c >=
'a' && c <=
'z'){
108 if(c >=
'A' && c <=
'Z'){
111 if(c >=
'0' && c <=
'9'){
125 if(!cur_token.empty()){
126 ret.push_back(cur_token);
130 cur_token.push_back(c);
133 if(!cur_token.empty()){
134 ret.push_back(cur_token);
Linux-specific utility functions.
bool is_bg_color_dark()
Determines if terminal background color is dark.
Json::Value read_json(string string_path)
Reads and parses a JSON file.
vector< string > split_string(string s, char delimiter)
Splits a string by a delimiter into tokens.
bool is_special_char(char c)
Checks if a character is special (non-alphanumeric and not underscore)
COLOR
Enumeration of available colors for formatted messages.
@ RESET
Reset to default color.
bool is_regular_file(string path)
Determines if a path refers to a regular file.
const vector< string > COLOR_TOKENS_UTILS_LIGTH
ANSI color codes for light terminal backgrounds.
void create_parents_folder_of_file_path(string file_path)
Creates all parent directories for a given file path.
bool does_file_exist(string file_path)
Checks if a file exists at the given path.
string format_colored_message(string message, COLOR color)
Formats a message with ANSI color codes.
bool is_empty_char(char c)
Checks if a character is considered empty/whitespace.
void ensure_file_is_open(std::ifstream &file, string file_name)
Ensures that a file stream is successfully opened.
vector< string > read_file_generic(string string_path)
Reads a file line by line into a vector of strings.
const int MKDIR_FLAG
Permission flags used when creating directories (rwx for owner)
const vector< string > COLOR_TOKENS_UTILS_DARK
ANSI color codes for dark terminal backgrounds.
void write_file_generic(string file_path, vector< string > content)
Writes content to a file at specified path.
Defines utility functions used across all files.
Windows-specific utility functions.