//+------------------------------------------------------------------+ //| File.mqh | //| Copyright 2026, Niquel Mendoza. | //| https://www.mql5.com/es/users/nique_372 | //+------------------------------------------------------------------+ #property copyright "Copyright 2026, Niquel Mendoza." #property link "https://www.mql5.com/es/users/nique_372" #property strict #ifndef MQLARTICLES_UTILS_FILE_FILE_MQH #define MQLARTICLES_UTILS_FILE_FILE_MQH //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #include "..\\FA\\Int\\String.mqh" //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void FolderRemoveBarraInvertida(string& folder_name) { const uint lenght = folder_name.Length(); if(lenght && folder_name[lenght - 1] == '\\') folder_name.Truncate(lenght - 1); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // a\l\h.py string PathGetDirectory(const string& path) { //--- const int idx = StringFindAtras(path, '\\', 1); if(idx == -1) return ""; //--- return StringSubstrRange(path, 0, idx); // incluye el \ } //+------------------------------------------------------------------+ string PathGetDirectoryNoRef(const string path) { //--- const int idx = StringFindAtras(path, '\\', 1); if(idx == -1) return ""; //--- return StringSubstrRange(path, 0, idx); // incluye el \ } // de un path le quita el \\ //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ string GetPureFileName(const string& filename) { const int in = StringFindAtras(filename, '\\', 1); // en caso file_name sea dir lo omitimos if(in == -1) return filename; else return StringSubstr(filename, in + 1); } //+------------------------------------------------------------------+ string GetPureFileNameNoRef(const string filename) { const int in = StringFindAtras(filename, '\\', 1); // en caso file_name sea dir lo omitimos if(in == -1) return filename; else return StringSubstr(filename, in + 1); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool FileHasExtension(const string& file_name, const string& extension) { const int in = StringFindAtras(file_name, '.'); if(in == -1) return false; else { return StringSubstr(file_name, in) == extension; } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ string FileGetExtension(const string& file_name) { const int in = StringFindAtras(file_name, '.'); if(in == -1) return ""; else return StringSubstr(file_name, in + 1); } //--- string FileGetExtensionNoRef(const string file_name) { const int in = StringFindAtras(file_name, '.'); if(in == -1) return ""; else return StringSubstr(file_name, in + 1); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ string FileRemoveExtension(const string& file_name) { const int in = StringFindAtras(file_name, '.'); if(in == -1) return file_name; else return StringSubstr(file_name, 0, in); } //+------------------------------------------------------------------+ string FileRemoveExtensionNoRef(const string file_name) { const int in = StringFindAtras(file_name, '.'); if(in == -1) return file_name; else return StringSubstr(file_name, 0, in); } //+------------------------------------------------------------------+ #endif // MQLARTICLES_UTILS_FILE_FILE_MQH