Example #1
0
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);
}
Example #2
0
Convert2Tlv::Convert2Tlv(const TFilePath &filepath1, const TFilePath &filepath2, const TFilePath &outFolder, const QString &outName,
						 int from, int to, bool doAutoclose, const TFilePath &palettePath, int colorTolerance,
						 int antialiasType, int antialiasValue, bool isUnpaintedFromNAA)
	: m_size(0, 0), m_level1(), m_levelIn1(), m_levelIn2(), m_levelOut(), m_autoclose(doAutoclose), m_premultiply(false), m_count(0), m_from(from), m_to(to), m_palettePath(palettePath), m_colorTolerance(colorTolerance), m_palette(0), m_antialiasType(antialiasType), m_antialiasValue(antialiasValue), m_isUnpaintedFromNAA(isUnpaintedFromNAA)
{
	if (filepath1 != TFilePath()) {
		m_levelIn1 = filepath1.getParentDir() + filepath1.getLevelName();
		if (outFolder != TFilePath())
			m_levelOut = m_levelIn1.withParentDir(outFolder).withNoFrame().withType("tlv");
		else
			m_levelOut = m_levelIn1.withNoFrame().withType("tlv"); //filePaths[0].getParentDir() + TFilePath(filePaths[0].getWideName() + L".tlv");

		if (outName != "")
			m_levelOut = m_levelOut.withName(outName.toStdString());
	}

	if (filepath2 != TFilePath())
		m_levelIn2 = filepath2.getParentDir() + filepath2.getLevelName();
}
Example #3
0
void TSystem::removeFileOrLevel_throw(const TFilePath &fp) {
  if (fp.isLevelName()) {
    TFilePathSet files;
    files = TSystem::readDirectory(fp.getParentDir(), false, true, true);

    TFilePathSet::iterator it, end = files.end();
    for (it = files.begin(); it != end; ++it) {
      if (it->getLevelName() == fp.getLevelName()) TSystem::deleteFile(*it);
    }
  } else
    TSystem::deleteFile(fp);
}