Пример #1
0
bool TxtPlugin::readLanguageAndEncoding(Book &book) const {
	shared_ptr<ZLInputStream> stream = book.file().inputStream();
	if (stream.isNull()) {
		return false;
	}
	detectEncodingAndLanguage(book, *stream);
	return !book.encoding().empty();
}
Пример #2
0
bool PluckerPlugin::readMetaInfo(Book &book) const {
	shared_ptr<ZLInputStream> stream = new PluckerTextStream(book.file());
	detectEncodingAndLanguage(book, *stream);
	if (book.encoding().empty()) {
		return false;
	}

	return true;
}
Пример #3
0
bool PluckerPlugin::readDescription(const std::string &path, BookDescription &description) const {
	ZLFile file(path);

	shared_ptr<ZLInputStream> stream = new PluckerTextStream(file);
	detectEncodingAndLanguage(description, *stream);
	if (description.encoding().empty()) {
		return false;
	}

	return true;
}
Пример #4
0
bool DocPlugin::readMetaInfo(Book &book) const {
	if (!DocMetaInfoReader(book).readMetaInfo()) {
		return false;
	}

	shared_ptr<ZLInputStream> stream = new DocCharStream(book.file(), 50000);
	if (!detectEncodingAndLanguage(book, *stream)) {
		stream = new DocAnsiStream(book.file(), 50000);
		detectLanguage(book, *stream, ZLEncodingConverter::UTF8, true);
	}

	return true;
}
Пример #5
0
bool HtmlPlugin::readMetaInfo(Book &book) const {
	shared_ptr<ZLInputStream> stream = book.file().inputStream();
	if (stream.isNull()) {
		return false;
	}

	shared_ptr<ZLInputStream> htmlStream = new HtmlReaderStream(stream, 50000);
	detectEncodingAndLanguage(book, *htmlStream);
	if (book.encoding().empty()) {
		return false;
	}
	HtmlDescriptionReader(book).readDocument(*stream);

	return true;
}
Пример #6
0
bool HtmlPlugin::readDescription(const std::string &path, BookDescription &description) const {
	ZLFile file(path);
	shared_ptr<ZLInputStream> stream = file.inputStream();
	if (stream.isNull()) {
		return false;
	}

	detectEncodingAndLanguage(description, *stream);
	if (description.encoding().empty()) {
		return false;
	}
	HtmlDescriptionReader(description).readDocument(*stream);
	defaultTitle(description, file.name());

	return true;
}
Пример #7
0
bool CHMPlugin::readDescription(const std::string &path, BookDescription &description) const {
	ZLFile file(path);
	shared_ptr<ZLInputStream> stream = file.inputStream();
	if (stream.isNull() || !stream->open()) {
		return false;
	}

	CHMFileInfo chmFile(path);
	if (!chmFile.init(*stream)) {
		return false;
	}

	CHMFileInfo::FileNames names = chmFile.sectionNames(stream);
	if (names.empty()) {
		return false;
	}

	/*
	shared_ptr<ZLInputStream> entryStream = chmFile.entryStream(stream, names.Start);
	if (entryStream.isNull()) {
		entryStream = chmFile.entryStream(stream, names.Home);
	}
	if (entryStream.isNull()) {
		entryStream = chmFile.entryStream(stream, names.TOC);
	}
	/ *
	if (entryStream.isNull()) {
		chmFile.entryStream(stream, names.Index);
	}
	* /
	if (entryStream.isNull()) {
		return false;
	}
	*/

	CHMTextStream textStream(chmFile, stream);
	detectEncodingAndLanguage(description, textStream);
	if (description.encoding().empty()) {
		return false;
	}

	return true;
}
Пример #8
0
bool CHMPlugin::readMetaInfo(Book &book) const {
    const ZLFile &file = book.file();
    shared_ptr<ZLInputStream> stream = file.inputStream();
    if (stream.isNull() || !stream->open()) {
        return false;
    }

    CHMFileInfo chmFile(file);
    if (!chmFile.init(*stream)) {
        return false;
    }

    CHMFileInfo::FileNames names = chmFile.sectionNames(stream);
    if (names.empty()) {
        return false;
    }

    /*
    shared_ptr<ZLInputStream> entryStream = chmFile.entryStream(stream, names.Start);
    if (entryStream.isNull()) {
    	entryStream = chmFile.entryStream(stream, names.Home);
    }
    if (entryStream.isNull()) {
    	entryStream = chmFile.entryStream(stream, names.TOC);
    }
    / *
    if (entryStream.isNull()) {
    	chmFile.entryStream(stream, names.Index);
    }
    * /
    if (entryStream.isNull()) {
    	return false;
    }
    */

    CHMTextStream textStream(chmFile, stream);
    detectEncodingAndLanguage(book, textStream);
    if (book.encoding().empty()) {
        return false;
    }

    return true;
}
Пример #9
0
bool SimplePdbPlugin::readMetainfo(Book &book) const {
	const ZLFile &file = book.file();
	shared_ptr<ZLInputStream> stream = createStream(file);
	detectEncodingAndLanguage(book, *stream);
	if (book.encoding().empty()) {
		return false;
	}
	int readType = HtmlMetainfoReader::NONE;
	if (book.title().empty()) {
		readType |= HtmlMetainfoReader::TITLE;
	}
	if (book.authors().empty()) {
		readType |= HtmlMetainfoReader::AUTHOR;
	}
	if (readType != HtmlMetainfoReader::NONE) {
	//if ((readType != HtmlMetainfoReader::NONE) && TextFormatDetector().isHtml(*stream)) {
		readType |= HtmlMetainfoReader::TAGS;
		HtmlMetainfoReader metainfoReader(book, (HtmlMetainfoReader::ReadType)readType);
		metainfoReader.readDocument(*stream);
	}

	return true;
}