1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-04 23:37:10 +02:00

Moved code to remove a file name extension into utilities module

This commit is contained in:
Maarten ter Huurne 2014-08-12 09:07:37 +02:00
parent aa5d8faeb6
commit 1e50dff746
2 changed files with 6 additions and 8 deletions

View File

@ -217,7 +217,6 @@ int Selector::exec(int startSelection) {
void Selector::prepare(FileLister *fl, vector<string> *titles) {
fl->setPath(dir);
titles->resize(fl->getFiles().size());
screendir = dir;
if (!screendir.empty() && screendir[screendir.length() - 1] != '/') {
@ -225,13 +224,8 @@ void Selector::prepare(FileLister *fl, vector<string> *titles) {
}
screendir += "previews/";
string noext;
string::size_type pos;
titles->resize(fl->getFiles().size());
for (uint i=0; i<fl->getFiles().size(); i++) {
noext = fl->getFiles()[i];
pos = noext.rfind(".");
if (pos!=string::npos && pos>0)
noext = noext.substr(0, pos);
titles->at(i) = noext;
titles->at(i) = trimExtension(fl->getFiles()[i]);
}
}

View File

@ -52,6 +52,10 @@ std::string readFileAsString(const char *filename);
std::string strreplace(std::string orig, const std::string &search, const std::string &replace);
std::string cmdclean(std::string cmdline);
inline std::string trimExtension(std::string const& filename) {
return filename.substr(0, filename.rfind('.'));
}
bool fileExists(const std::string &file);
bool rmtree(std::string path);