本文整理汇总了C++中TFilePathSet类的典型用法代码示例。如果您正苦于以下问题:C++ TFilePathSet类的具体用法?C++ TFilePathSet怎么用?C++ TFilePathSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TFilePathSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readDirectory
/*! to retrieve the both lists with groupFrames option = on and off.
*/
void TSystem::readDirectory(TFilePathSet &groupFpSet, TFilePathSet &allFpSet,
const TFilePath &path) {
if (!TFileStatus(path).isDirectory())
throw TSystemException(path, " is not a directory");
std::set<TFilePath, CaselessFilepathLess> fileSet_group;
std::set<TFilePath, CaselessFilepathLess> fileSet_all;
QStringList fil =
QDir(toQString(path))
.entryList(QDir::Files | QDir::NoDotAndDotDot | QDir::Readable);
if (fil.size() == 0) return;
for (int i = 0; i < fil.size(); i++) {
QString fi = fil.at(i);
TFilePath son = path + TFilePath(fi.toStdWString());
// store all file paths
fileSet_all.insert(son);
// in case of the sequencial files
if (son.getDots() == "..") son = son.withFrame();
// store the group. insersion avoids duplication of the item
fileSet_group.insert(son);
}
groupFpSet.insert(groupFpSet.end(), fileSet_group.begin(),
fileSet_group.end());
allFpSet.insert(allFpSet.end(), fileSet_all.begin(), fileSet_all.end());
}
示例2: TFilePath
void InsertFxPopup::loadMacro()
{
TFilePath fp = m_presetFolder + TFilePath("macroFx");
try {
if (TFileStatus(fp).isDirectory()) {
TFilePathSet macros = TSystem::readDirectory(fp);
if (macros.empty())
return;
QTreeWidgetItem *macroFolder = new QTreeWidgetItem((QTreeWidget *)0, QStringList(tr("Macro")));
macroFolder->setData(0, Qt::UserRole, QVariant(toQString(fp)));
macroFolder->setIcon(0, m_folderIcon);
m_fxTree->addTopLevelItem(macroFolder);
for (TFilePathSet::iterator it = macros.begin(); it != macros.end(); ++it) {
TFilePath macroPath = *it;
QString name(macroPath.getName().c_str());
QTreeWidgetItem *macroItem = new QTreeWidgetItem((QTreeWidget *)0, QStringList(name));
macroItem->setData(0, Qt::UserRole, QVariant(toQString(macroPath)));
macroItem->setIcon(0, m_fxIcon);
macroFolder->addChild(macroItem);
}
}
} catch (...) {
}
}
示例3: catch
bool TSystem::doesExistFileOrLevel(const TFilePath &fp) {
if (TFileStatus(fp).doesExist()) return true;
if (fp.isLevelName()) {
const TFilePath &parentDir = fp.getParentDir();
if (!TFileStatus(parentDir).doesExist()) return false;
TFilePathSet files;
try {
files = TSystem::readDirectory(parentDir, false, true, true);
} catch (...) {
}
TFilePathSet::iterator it, end = files.end();
for (it = files.begin(); it != end; ++it) {
if (it->getLevelNameW() == fp.getLevelNameW()) return true;
}
} else if (fp.getType() == "psd") {
QString name(QString::fromStdWString(fp.getWideName()));
name.append(QString::fromStdString(fp.getDottedType()));
int sepPos = name.indexOf("#");
int dotPos = name.indexOf(".", sepPos);
int removeChars = dotPos - sepPos;
int doubleUnderscorePos = name.indexOf("__", sepPos);
if (doubleUnderscorePos > 0) removeChars = doubleUnderscorePos - sepPos;
name.remove(sepPos, removeChars);
TFilePath psdpath(fp.getParentDir() + TFilePath(name.toStdWString()));
if (TFileStatus(psdpath).doesExist()) return true;
}
return false;
}
示例4: presetsFilepath
bool InsertFxPopup::loadPreset(QTreeWidgetItem *item)
{
QString str = item->data(0, Qt::UserRole).toString();
TFilePath presetsFilepath(m_presetFolder + str.toStdWString());
int i;
for (i = item->childCount() - 1; i >= 0; i--)
item->removeChild(item->child(i));
if (TFileStatus(presetsFilepath).isDirectory()) {
TFilePathSet presets = TSystem::readDirectory(presetsFilepath);
if (!presets.empty()) {
for (TFilePathSet::iterator it2 = presets.begin(); it2 != presets.end(); ++it2) {
TFilePath presetPath = *it2;
QString name(presetPath.getName().c_str());
QTreeWidgetItem *presetItem = new QTreeWidgetItem((QTreeWidget *)0, QStringList(name));
presetItem->setData(0, Qt::UserRole, QVariant(toQString(presetPath)));
item->addChild(presetItem);
presetItem->setIcon(0, m_fxIcon);
}
} else
return false;
} else
return false;
return true;
}
示例5: updateChooseProjectCombo
void ProjectPopup::updateChooseProjectCombo() {
m_projectPaths.clear();
m_chooseProjectCombo->clear();
TFilePath sandboxFp = TProjectManager::instance()->getSandboxProjectFolder() +
"sandbox_otprj.xml";
m_projectPaths.push_back(sandboxFp);
m_chooseProjectCombo->addItem("sandbox");
std::vector<TFilePath> prjRoots;
TProjectManager::instance()->getProjectRoots(prjRoots);
for (int i = 0; i < prjRoots.size(); i++) {
TFilePathSet fps;
TSystem::readDirectory_Dir_ReadExe(fps, prjRoots[i]);
TFilePathSet::iterator it;
for (it = fps.begin(); it != fps.end(); ++it) {
TFilePath fp(*it);
if (TProjectManager::instance()->isProject(fp)) {
m_projectPaths.push_back(
TProjectManager::instance()->projectFolderToProjectPath(fp));
m_chooseProjectCombo->addItem(QString::fromStdString(fp.getName()));
}
}
}
for (int i = 0; i < m_projectPaths.size(); i++) {
if (TProjectManager::instance()->getCurrentProjectPath() ==
m_projectPaths[i]) {
m_chooseProjectCombo->setCurrentIndex(i);
break;
}
}
}
示例6: srcpltname
void TSystem::renameFileOrLevel_throw(const TFilePath &dst,
const TFilePath &src,
bool renamePalette) {
if (renamePalette && ((src.getType() == "tlv") || (src.getType() == "tzp") ||
(src.getType() == "tzu"))) {
// Special case: since renames cannot be 'grouped' in the UI, palettes are
// automatically
// renamed here if required
const char *type = (src.getType() == "tlv") ? "tpl" : "plt";
TFilePath srcpltname(src.withNoFrame().withType(type));
TFilePath dstpltname(dst.withNoFrame().withType(type));
if (TSystem::doesExistFileOrLevel(src) &&
TSystem::doesExistFileOrLevel(srcpltname))
TSystem::renameFile(dstpltname, srcpltname, false);
}
if (src.isLevelName()) {
TFilePathSet files;
files = TSystem::readDirectory(src.getParentDir(), false);
for (TFilePathSet::iterator it = files.begin(); it != files.end(); it++) {
if (it->getLevelName() == src.getLevelName()) {
TFilePath src1 = *it;
TFilePath dst1 = dst.withFrame(it->getFrame());
TSystem::renameFile(dst1, src1);
}
}
} else
TSystem::renameFile(dst, src);
}
示例7: getBrushesDirs
TFilePathSet TMyPaintBrushStyle::getBrushesDirs() {
TFilePathSet paths;
paths.push_back(m_libraryDir + "mypaint brushes");
QStringList genericLocations = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
for(QStringList::iterator i = genericLocations.begin(); i != genericLocations.end(); ++i)
paths.push_back(TFilePath(*i) + "mypaint" + "brushes");
return paths;
}
示例8: getDisks
TFilePathSet TSystem::getDisks() {
TFilePathSet filePathSet;
QFileInfoList fil = QDir::drives();
int i;
for (i = 0; i < fil.size(); i++)
filePathSet.push_back(TFilePath(fil.at(i).filePath().toStdWString()));
return filePathSet;
}
示例9: hideFileOrLevel_throw
void TSystem::hideFileOrLevel_throw(const TFilePath &fp) {
if (fp.isLevelName()) {
TFilePathSet files;
files = TSystem::readDirectory(fp.getParentDir(), false);
TFilePathSet::iterator it, end = files.end();
for (it = files.begin(); it != end; ++it) {
if (it->getLevelNameW() == fp.getLevelNameW()) TSystem::hideFile(*it);
}
} else
TSystem::hideFile(fp);
}
示例10: packLevelNames
TFilePathSet TSystem::packLevelNames(const TFilePathSet &fps) {
std::set<TFilePath> tmpSet;
TFilePathSet::const_iterator cit;
for (cit = fps.begin(); cit != fps.end(); ++cit)
tmpSet.insert(cit->getParentDir() + cit->getLevelName());
TFilePathSet fps2;
for (std::set<TFilePath>::const_iterator c_sit = tmpSet.begin();
c_sit != tmpSet.end(); ++c_sit) {
fps2.push_back(*c_sit);
}
return fps2;
}
示例11: getSystemVarPathSetValue
TFilePathSet TEnv::getSystemVarPathSetValue(std::string varName) {
TFilePathSet lst;
std::string value = EnvGlobals::instance()->getSystemVarValue(varName);
int len = (int)value.size();
int i = 0;
int j = value.find(';');
while (j != std::string::npos) {
std::string s = value.substr(i, j - i);
lst.push_back(TFilePath(s));
i = j + 1;
if (i >= len) return lst;
j = value.find(';', i);
}
if (i < len) lst.push_back(TFilePath(value.substr(i)));
return lst;
}
示例12: levelName
TLevelP TLevelReader::loadInfo()
{
TFilePath parentDir = m_path.getParentDir();
TFilePath levelName(m_path.getLevelName());
// cout << "Parent dir = '" << parentDir << "'" << endl;
// cout << "Level name = '" << levelName << "'" << endl;
TFilePathSet files;
try {
files = TSystem::readDirectory(parentDir, false, true, true);
} catch (...) {
throw TImageException(m_path, "unable to read directory content");
}
TLevelP level;
vector<TFilePath> data;
for (TFilePathSet::iterator it = files.begin(); it != files.end(); it++) {
TFilePath ln(it->getLevelName());
// cout << "try " << *it << " " << it->getLevelName() << endl;
if (levelName == TFilePath(it->getLevelName())) {
try {
level->setFrame(it->getFrame(), TImageP());
data.push_back(*it);
} catch (string msg) {
throw msg;
}
}
}
if (!data.empty()) {
std::vector<TFilePath>::iterator it = std::min_element(data.begin(), data.end(), myLess);
TFilePath fr = (*it).withoutParentDir().withName("").withType("");
wstring ws = fr.getWideString();
if (ws.length() == 5) {
if (ws.rfind(L'_') == (int)wstring::npos)
m_frameFormat = TFrameId::FOUR_ZEROS;
else
m_frameFormat = TFrameId::UNDERSCORE_FOUR_ZEROS;
} else {
if (ws.rfind(L'_') == (int)wstring::npos)
m_frameFormat = TFrameId::NO_PAD;
else
m_frameFormat = TFrameId::UNDERSCORE_NO_PAD;
}
} else
m_frameFormat = TFrameId::FOUR_ZEROS;
return level;
}
示例13: copyFileOrLevel_throw
void TSystem::copyFileOrLevel_throw(const TFilePath &dst,
const TFilePath &src) {
if (src.isLevelName()) {
TFilePathSet files;
files = TSystem::readDirectory(src.getParentDir(), false);
TFilePathSet::iterator it, end = files.end();
for (it = files.begin(); it != end; ++it) {
if (it->getLevelNameW() == src.getLevelNameW()) {
TFilePath src1 = *it;
TFilePath dst1 = dst.withFrame(it->getFrame());
TSystem::copyFile(dst1, src1);
}
}
} else
TSystem::copyFile(dst, src);
}
示例14: catch
void TPaperFormatManager::readPaperFormats() {
TFilePathSet fps;
TFilePath papDir = TEnv::getConfigDir() + "pap";
if (!TFileStatus(papDir).isDirectory()) {
// TMessage::error("E_CanNotReadDirectory_%1", papDir);
return;
}
try {
fps = TSystem::readDirectory(papDir);
} catch (TException &) {
// TMessage::error("E_CanNotReadDirectory_%1", papDir);
return;
}
TFilePathSet::const_iterator it = fps.begin();
for (; it != fps.end(); ++it) readPaperFormat(*it);
}
示例15: TFilePath
void AddFxContextMenu::loadMacro() {
TFilePath macroDir = m_presetPath + TFilePath("macroFx");
try {
if (TFileStatus(macroDir).isDirectory()) {
TFilePathSet macros = TSystem::readDirectory(macroDir);
if (macros.empty()) return;
QMenu *insertMacroMenu = new QMenu("Macro", m_insertMenu);
QMenu *addMacroMenu = new QMenu("Macro", m_addMenu);
QMenu *replaceMacroMenu = new QMenu("Macro", m_replaceMenu);
m_insertMenu->addMenu(insertMacroMenu);
m_addMenu->addMenu(addMacroMenu);
m_replaceMenu->addMenu(replaceMacroMenu);
for (TFilePathSet::iterator it = macros.begin(); it != macros.end();
++it) {
TFilePath macroPath = *it;
QString name = QString::fromStdWString(macroPath.getWideName());
QAction *insertAction = new QAction(name, insertMacroMenu);
QAction *addAction = new QAction(name, addMacroMenu);
QAction *replaceAction = new QAction(name, replaceMacroMenu);
insertAction->setData(
QVariant(QString::fromStdWString(macroPath.getWideString())));
addAction->setData(
QVariant(QString::fromStdWString(macroPath.getWideString())));
replaceAction->setData(
QVariant(QString::fromStdWString(macroPath.getWideString())));
insertMacroMenu->addAction(insertAction);
addMacroMenu->addAction(addAction);
replaceMacroMenu->addAction(replaceAction);
m_insertActionGroup->addAction(insertAction);
m_addActionGroup->addAction(addAction);
m_replaceActionGroup->addAction(replaceAction);
}
}
} catch (...) {
}
}