Home | Develop | Download | Contact
example_ra_file.cpp
1
52#include <Pds/Ra>
53
54
55int main(void)
56{
57 std::string filepath;
58 filepath=Pds::Ra::FullFile({"/usr","share/","program_name","icons","image.png"});
59 std::cout<<" filepath: "<<filepath<<std::endl;
60 filepath=Pds::Ra::FullFile({"/usr","share","program_name","icons","image.png"});
61 std::cout<<" filepath: "<<filepath<<std::endl;
62
63 std::cout<<" dirname: "<<Pds::Ra::Dirname(filepath)<<std::endl;
64 std::cout<<" basename: "<<Pds::Ra::Basename(filepath)<<std::endl;
65 std::cout<<"extension: "<<Pds::Ra::Extension(filepath)<<std::endl;
66 std::cout<<" filename: "<<Pds::Ra::Filename(filepath)<<std::endl;
67
68 std::cout<<std::endl;
69
70 std::cout<<"replaceex: "<<Pds::Ra::ReplaceExtension(filepath,"bmp")<<std::endl;
71
72 std::cout<<std::endl;
73
74 if(Pds::Ra::IsFile(filepath)) std::cout<<"Exist the file: "<<filepath<<std::endl;
75 else std::cout<<"NO exist the file: "<<filepath<<std::endl;
76
78 std::cout<<"Exist the directory: "<<Pds::Ra::HomeDir()<<std::endl;
79 else
80 std::cout<<"NO exist the directory: "<<Pds::Ra::HomeDir()<<std::endl;
81
83 std::cout<<"Exist the directory: "<<Pds::Ra::HomeDir()+Pds::Ra::FileSep+"XXX"<<std::endl;
84 else
85 std::cout<<"NO exist the directory: "<<Pds::Ra::HomeDir()+Pds::Ra::FileSep+"XXX"<<std::endl;
86
87 std::string str3=" hola\t \n como\n \n estas \n \t \n tu \n";
88 Pds::Ra::SaveString("testando.txt",str3);
89 std::cout<<"str3:\n"<<str3<<"\n";
90
91 std::string str4;
92 Pds::Ra::LoadString("testando.txt",str4);
93 std::cout<<"str4:\n"<<str4<<"\n";
94
95 std::cout<<"GenSignificativeLines(\"testando.txt\"):\n";
96 std::vector<std::string> line;
97 line=Pds::Ra::GenSignificativeLines("testando.txt");
99
100}
std::string HomeDir(void)
Retorna una nueva cadena de texto con la dirección del directorio de usuario. HOME en gnu-linux y {HO...
const std::string FileSep
std::string con un separador de fichero "\\" para WINDOWS y "/" para linux.
Definition: RaCmd.hpp:72
std::string Filename(std::string filepath)
Retorna un std::string con el filename de un filepath.
std::vector< std::string > GenSignificativeLines(const std::string &filepath)
Retorna un vector de cadenas con las lineas significativas (no vacias) del archivo....
std::string ReplaceExtension(std::string filepath, std::string new_ext)
Retorna un std::string con un filepath con otra extension de un filepath.
std::string Basename(std::string filepath)
Retorna un std::string con el basename de un filepath.
std::string Extension(std::string filepath)
Retorna un std::string con el extension de un filepath.
std::string FullFile(std::vector< std::string > str_text_list)
Retorna una nueva cadena con un filepath creado por la union de las cadenas de entrada,...
bool IsFile(std::string path)
Retorna true si es un fichero existenteste (simbólico o real) no directorio, o false si no.
std::string Dirname(std::string filepath)
Retorna un std::string con el directorio de un filepath.
bool IsDir(std::string path)
Retorna true si es un directorio existenteste (simbólico o real) no fichero, o false si no.
bool SaveString(const std::string &filepath, const std::string &str)
Save the string in a text file.
bool PrintVectorString(const std::vector< std::string > &str)
Print each string of a vector string in a new line in a text file.
bool LoadString(const std::string &filepath, std::string &str)
Load the string in a text file.

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed