// Checked: 2010-08-30 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c void RlvForceWear::addWearable(const LLViewerInventoryItem* pItem, EWearAction eAction) { const LLViewerWearable* pWearable = gAgentWearables.getWearableFromItemID(pItem->getLinkedUUID()); // When replacing remove all currently worn wearables of this type *unless* the item is currently worn if ( (ACTION_WEAR_REPLACE == eAction) && (!pWearable) ) forceRemove(pItem->getWearableType()); // Remove it from 'm_remWearables' if it's pending removal if ( (pWearable) && (isRemWearable(pWearable)) ) m_remWearables.erase(std::remove(m_remWearables.begin(), m_remWearables.end(), pWearable), m_remWearables.end()); addwearables_map_t::iterator itAddWearables = m_addWearables.find(pItem->getWearableType()); if (itAddWearables == m_addWearables.end()) { m_addWearables.insert(addwearable_pair_t(pItem->getWearableType(), LLInventoryModel::item_array_t())); itAddWearables = m_addWearables.find(pItem->getWearableType()); } if (ACTION_WEAR_ADD == eAction) // Add it at the back if it's not already there { if (!isAddWearable(pItem)) itAddWearables->second.push_back((LLViewerInventoryItem*)pItem); } else if (ACTION_WEAR_REPLACE == eAction) // Replace all pending wearables of this type with the specified item { itAddWearables->second.clear(); itAddWearables->second.push_back((LLViewerInventoryItem*)pItem); } }
/** * This function will first remove system cache files, e.g. `Thumbs.db`, * `.DS_Store`. Then will try to remove the whole tree if the tree consist * only of folders */ bool Utils::Fs::smartRemoveEmptyFolderTree(const QString &path) { if (path.isEmpty() || !QDir(path).exists()) return true; static const QStringList deleteFilesList = { // Windows "Thumbs.db", "desktop.ini", // Linux ".directory", // Mac OS ".DS_Store" }; // travel from the deepest folder and remove anything unwanted on the way out. QStringList dirList(path + "/"); // get all sub directories paths QDirIterator iter(path, (QDir::AllDirs | QDir::NoDotAndDotDot), QDirIterator::Subdirectories); while (iter.hasNext()) dirList << iter.next() + "/"; // sort descending by directory depth std::sort(dirList.begin(), dirList.end() , [](const QString &l, const QString &r) { return l.count("/") > r.count("/"); }); for (const QString &p : qAsConst(dirList)) { // remove unwanted files for (const QString &f : deleteFilesList) { forceRemove(p + f); } // remove temp files on linux (file ends with '~'), e.g. `filename~` QDir dir(p); QStringList tmpFileList = dir.entryList(QDir::Files); for (const QString &f : tmpFileList) { if (f.endsWith("~")) forceRemove(p + f); } // remove directory if empty dir.rmdir(p); } return QDir(path).exists(); }
// Checked: 2010-03-19 (RLVa-1.2.0a) | Added: RLVa-1.2.0a void RlvForceWear::forceRemove(LLWearableType::EType wtType) { for (U32 idxWearable = 0, cntWearable = gAgentWearables.getWearableCount(wtType); idxWearable < cntWearable; idxWearable++) forceRemove(gAgentWearables.getViewerWearable(wtType, idxWearable)); }
// Checked: 2010-03-19 (RLVa-1.1.3a) | Added: RLVa-1.2.0a void RlvForceWear::forceRemove(EWearableType wtType) { forceRemove(gAgent.getWearable(wtType)); }