Example #1
0
void TLevelSet::removeFolder(const TFilePath &folder) {
  if (folder == m_defaultFolder) return;
  std::vector<TFilePath> folders;
  for (int i = 0; i < (int)m_folders.size(); i++)
    if (!folder.isAncestorOf(m_folders[i])) folders.push_back(m_folders[i]);
  folders.swap(m_folders);
  std::map<TXshLevel *, TFilePath>::iterator it;
  for (it = m_folderTable.begin(); it != m_folderTable.end(); ++it) {
    if (folder.isAncestorOf(it->second)) it->second = m_defaultFolder;
  }
}
Example #2
0
TFilePath TFilePath::operator-(const TFilePath &fp) const {
#ifdef WIN32
  if (toLower(m_path) == toLower(fp.m_path)) return TFilePath("");
#else
  if (m_path == fp.m_path) return TFilePath("");
#endif
  if (!fp.isAncestorOf(*this)) return *this;
  int len = fp.m_path.length();
  if (len == 0 || fp.m_path[len - 1] != slash) len++;

  return TFilePath(m_path.substr(len));
}
Example #3
0
TFilePath TLevelSet::renameFolder(const TFilePath &folder,
                                  const std::wstring &newName) {
  // Impedisco la creazione di folder con nome "" che creano problemi
  // (praticamente Ecome se avessero infinite sottocartelle)
  if (newName == L"") return folder;

  TFilePath folder2 = folder.withName(newName);

  for (int i = 0; i < (int)m_folders.size(); i++) {
    if (folder == m_folders[i])
      m_folders[i] = folder2;
    else if (folder.isAncestorOf(m_folders[i]))
      m_folders[i] = folder2 + (m_folders[i] - folder);
  }
  if (m_defaultFolder == folder) m_defaultFolder = folder2;
  std::map<TXshLevel *, TFilePath>::iterator it;
  for (it = m_folderTable.begin(); it != m_folderTable.end(); ++it) {
    if (folder == it->second)
      it->second = folder2;
    else if (folder.isAncestorOf(it->second))
      it->second = folder2 + (it->second - folder);
  }
  return folder2;
}