void ResourceCollector::process(TXshSimpleLevel *sl)
{
	TFilePath path = sl->getPath();
	std::string suffix = ResourceImporter::extractPsdSuffix(path);
	std::map<TFilePath, TFilePath>::iterator it = m_collectedFiles.find(path);
	if (it != m_collectedFiles.end()) {
		TFilePath destPath = it->second;
		if (suffix != "")
			destPath = ResourceImporter::buildPsd(destPath, suffix);
		sl->setPath(destPath);
	} else {
		TFilePath collectedPath = path;
		if (getCollectedPath(m_scene, collectedPath)) {
			TFilePath actualCollectedPath = m_scene->decodeFilePath(collectedPath);
			if (actualCollectedPath != path && TSystem::doesExistFileOrLevel(path) &&
				!TSystem::doesExistFileOrLevel(actualCollectedPath)) {
				try {
					TSystem::touchParentDir(actualCollectedPath);
					TXshSimpleLevel::copyFiles(actualCollectedPath, path);
				} catch (...) {
				}
			}
			++m_count;
			TFilePath destPath = collectedPath;
			if (suffix != "")
				destPath = ResourceImporter::buildPsd(destPath, suffix);
			sl->setPath(destPath);
			m_collectedFiles[path] = collectedPath;
		}
	}

	if (sl->getScannedPath() != TFilePath()) {
		path = sl->getScannedPath();
		TFilePath collectedPath = path;
		if (getCollectedPath(m_scene, collectedPath)) {
			TFilePath actualCollectedPath = m_scene->decodeFilePath(collectedPath);
			if (actualCollectedPath != path && TSystem::doesExistFileOrLevel(path)) {
				try {
					TSystem::touchParentDir(actualCollectedPath);
					TXshSimpleLevel::copyFiles(actualCollectedPath, path);
				} catch (...) {
				}
			}
			sl->setScannedPath(collectedPath);
			m_count++;
		}
	}
	sl->setDirtyFlag(false);
}
Beispiel #2
0
void ResourceCollector::process(TXshPaletteLevel *pl) {
  TFilePath path          = pl->getPath();
  TFilePath collectedPath = path;
  if (!getCollectedPath(m_scene, collectedPath)) return;

  TFilePath actualCollectedPath = m_scene->decodeFilePath(collectedPath);
  if (actualCollectedPath != path && TSystem::doesExistFileOrLevel(path)) {
    try {
      TSystem::touchParentDir(actualCollectedPath);
      TXshSimpleLevel::copyFiles(actualCollectedPath, path);

    } catch (...) {
    }
  }
  pl->setPath(collectedPath);
  m_count++;
}