mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-29 02:10:38 +02:00
Moved code to remove a file name extension into utilities module
This commit is contained in:
parent
aa5d8faeb6
commit
1e50dff746
@ -217,7 +217,6 @@ int Selector::exec(int startSelection) {
|
|||||||
|
|
||||||
void Selector::prepare(FileLister *fl, vector<string> *titles) {
|
void Selector::prepare(FileLister *fl, vector<string> *titles) {
|
||||||
fl->setPath(dir);
|
fl->setPath(dir);
|
||||||
titles->resize(fl->getFiles().size());
|
|
||||||
|
|
||||||
screendir = dir;
|
screendir = dir;
|
||||||
if (!screendir.empty() && screendir[screendir.length() - 1] != '/') {
|
if (!screendir.empty() && screendir[screendir.length() - 1] != '/') {
|
||||||
@ -225,13 +224,8 @@ void Selector::prepare(FileLister *fl, vector<string> *titles) {
|
|||||||
}
|
}
|
||||||
screendir += "previews/";
|
screendir += "previews/";
|
||||||
|
|
||||||
string noext;
|
titles->resize(fl->getFiles().size());
|
||||||
string::size_type pos;
|
|
||||||
for (uint i=0; i<fl->getFiles().size(); i++) {
|
for (uint i=0; i<fl->getFiles().size(); i++) {
|
||||||
noext = fl->getFiles()[i];
|
titles->at(i) = trimExtension(fl->getFiles()[i]);
|
||||||
pos = noext.rfind(".");
|
|
||||||
if (pos!=string::npos && pos>0)
|
|
||||||
noext = noext.substr(0, pos);
|
|
||||||
titles->at(i) = noext;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 strreplace(std::string orig, const std::string &search, const std::string &replace);
|
||||||
std::string cmdclean(std::string cmdline);
|
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 fileExists(const std::string &file);
|
||||||
bool rmtree(std::string path);
|
bool rmtree(std::string path);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user