コード例 #1
0
ファイル: module.cpp プロジェクト: clone2727/xoreos
Common::UString Module::getDescription(const Common::UString &module) {
	try {
		const Common::FileList modules(ConfigMan.getString("NWN2_moduleDir"));

		const Aurora::ERFFile mod(new Common::ReadFile(modules.findFirst(module + ".mod", true)));
		const uint32 ifoIndex = mod.findResource("module", Aurora::kFileTypeIFO);

		const Aurora::GFF3File ifo(mod.getResource(ifoIndex), MKTAG('I', 'F', 'O', ' '));

		return ifo.getTopLevel().getString("Mod_Description");

	} catch (...) {
	}

	return "";
}
コード例 #2
0
ファイル: unerf.cpp プロジェクト: idkwim/xoreos-tools
void extractFiles(Aurora::ERFFile &erf, Aurora::GameID game,
                  std::set<Common::UString> &files, ExtractMode mode) {

    const Aurora::Archive::ResourceList &resources = erf.getResources();
    const size_t fileCount = resources.size();

    std::printf("Number of files: %u\n\n", (uint)fileCount);

    size_t i = 1;
    for (Aurora::Archive::ResourceList::const_iterator r = resources.begin(); r != resources.end(); ++r, ++i) {
        Common::UString name = r->name;
        if (name.empty())
            findHashedName(r->hash, name);

        name.replaceAll('\\', '/');

        if (mode == kExtractModeStrip)
            name = Common::FilePath::getFile(name);

        const Aurora::FileType type = TypeMan.aliasFileType(r->type, game);
        Common::UString fileName = TypeMan.addFileType(name, type);

        if (!files.empty() && (files.find(fileName) == files.end()))
            continue;

        if (mode == kExtractModeSubstitute)
            fileName.replaceAll('/', '=');

        std::printf("Extracting %u/%u: %s ... ", (uint)i, (uint)fileCount, fileName.c_str());

        Common::SeekableReadStream *stream = 0;
        try {
            stream = erf.getResource(r->index);

            dumpStream(*stream, fileName);

            std::printf("Done\n");
        } catch (Common::Exception &e) {
            Common::printException(e, "");
        }

        delete stream;
    }

}
コード例 #3
0
ファイル: unerf.cpp プロジェクト: idkwim/xoreos-tools
void listFiles(Aurora::ERFFile &erf, Aurora::GameID game) {
    const Aurora::Archive::ResourceList &resources = erf.getResources();
    const size_t fileCount = resources.size();

    std::printf("Number of files: %u\n\n", (uint)fileCount);

    std::printf("              Filename               |    Size\n");
    std::printf("=====================================|===========\n");

    for (Aurora::Archive::ResourceList::const_iterator r = resources.begin(); r != resources.end(); ++r) {
        const Aurora::FileType type = TypeMan.aliasFileType(r->type, game);

        Common::UString name = r->name;
        if (name.empty())
            findHashedName(r->hash, name);

        name = Common::FilePath::getFile(name);

        std::printf("%32s%-4s | %10d\n", name.c_str(), TypeMan.setFileType("", type).c_str(),
                    erf.getResourceSize(r->index));
    }
}
コード例 #4
0
ファイル: unerf.cpp プロジェクト: cc9cii/xoreos-tools
void displayInfo(Aurora::ERFFile &erf) {
	std::printf("Version: %s\n", Common::debugTag(erf.getVersion()).c_str());
	std::printf("Build Year: %d\n", erf.getBuildYear());
	std::printf("Build Day: %d\n", erf.getBuildDay());
	std::printf("Number of files: %u\n", (uint)erf.getResources().size());

	const Aurora::LocString &description = erf.getDescription();
	if (description.getString().empty() && (description.getID() == Aurora::kStrRefInvalid))
		return;

	std::printf("\nDescription:\n");
	std::printf("String reference ID: %u\n", description.getID());

	std::vector<Aurora::LocString::SubLocString> str;
	description.getStrings(str);

	for (std::vector<Aurora::LocString::SubLocString>::iterator s = str.begin(); s != str.end(); ++s) {
		std::printf("\n.=== Description in language %u: ===\n", s->language);
		std::printf("%s\n", s->str.c_str());
		std::printf("'=== ===\n");
	}
}
コード例 #5
0
ファイル: unerf.cpp プロジェクト: idkwim/xoreos-tools
void listVerboseFiles(Aurora::ERFFile &erf, Aurora::GameID game) {
    const Aurora::Archive::ResourceList &resources = erf.getResources();
    const size_t fileCount = resources.size();

    std::printf("Number of files: %u\n\n", (uint)fileCount);

    std::vector<FileEntry> fileEntries;
    fileEntries.reserve(fileCount);

    size_t nameLength = 10;
    for (Aurora::Archive::ResourceList::const_iterator r = resources.begin(); r != resources.end(); ++r) {
        const Aurora::FileType type = TypeMan.aliasFileType(r->type, game);

        Common::UString name = r->name;
        if (name.empty())
            findHashedName(r->hash, name);

        name.replaceAll('\\', '/');

        name = TypeMan.addFileType(name, type);

        nameLength = MAX<size_t>(nameLength, name.size() + 1);

        fileEntries.push_back(FileEntry(name, erf.getResourceSize(r->index)));
    }

    if ((nameLength % 2) == 1)
        nameLength++;

    std::printf("%sFileName%s|    Size\n", Common::UString(' ', (nameLength - 8) / 2).c_str(),
                Common::UString(' ', (nameLength - 8) / 2).c_str());
    std::printf("%s|===========\n", Common::UString('=', nameLength).c_str());

    for (std::vector<FileEntry>::const_iterator f = fileEntries.begin(); f != fileEntries.end(); ++f)
        std::printf("%-*s| %10d\n", (int)nameLength, f->file.c_str(), f->size);
}