#include "../tool/file_tools.h"
#include <fstream>
#include <stdlib.h>
#include "i18n.h"
Include dependency graph for file_tools.cpp:
Go to the source code of this file.
Functions | |
bool | IsFileExist (const std::string &name) |
std::string | FileExtension (const std::string &name) |
std::string | GetHome () |
std::string | TranslateDirectory (const std::string &directory) |
std::string FileExtension | ( | const std::string & | name | ) |
Definition at line 44 of file file_tools.cpp.
00045 { 00046 int pos = name.rfind('.'); 00047 if (pos != -1) 00048 return name.substr(pos+1); 00049 else 00050 return ""; 00051 }
std::string GetHome | ( | ) |
Definition at line 55 of file file_tools.cpp.
00056 { 00057 char *txt = getenv("HOME"); 00058 00059 if (txt == NULL) 00060 Error (_("HOME directory (environment variable $HOME) could not be found!")); 00061 00062 return txt; 00063 }
Here is the caller graph for this function:
bool IsFileExist | ( | const std::string & | name | ) |
Definition at line 35 of file file_tools.cpp.
00036 { 00037 std::ifstream f(name.c_str()); 00038 bool exist = f; 00039 f.close(); 00040 return exist; 00041 }
Here is the caller graph for this function:
std::string TranslateDirectory | ( | const std::string & | directory | ) |
Definition at line 79 of file file_tools.cpp.
00080 { 00081 std::string home = GetHome(); 00082 std::string txt = directory; 00083 00084 for (int pos = txt.length()-1; 00085 (pos = txt.rfind ('~', pos)) != -1; 00086 --pos) 00087 { 00088 txt.replace(pos,1,home); 00089 } 00090 return txt; 00091 }
Here is the call graph for this function:
Here is the caller graph for this function: