26 _fileName(fileName), _filePosition(filePosition),
27 _hasFileSize(false), _io(NULL), _newIO(NULL)
73 if(fileName.size() > 20) {
82 if(fileDir.size() > 128) {
91 int index = filePath.lastIndexOf(
'/');
147 QByteArray name = lgp->read(20);
148 if(name.size() != 20) {
151 if(QString(name).compare(
fileName(), Qt::CaseInsensitive) != 0) {
152 qWarning() <<
"different name";
157 if(lgp->read((
char *)&size, 4) != 4) {
163 QIODevice *io =
new LgpIO(lgp,
this);
169 QIODevice(parent),
_lgp(lgp), _header(header)
174 if(mode.testFlag(QIODevice::Append)
175 || mode.testFlag(QIODevice::Truncate)) {
178 return QIODevice::open(mode);
193 return _lgp->read(data, qMin(maxSize, size - pos()));
208 return _lgp->write(data, qMin(maxSize, size - pos()));
215 return pos() <
size();
236 qint32 v = lookupValue(entry->
fileName());
252 qint32 v = lookupValue(filePath);
257 return entry(filePath, v);
278 if(filePath.compare(entry->
filePath(), Qt::CaseInsensitive) == 0) {
288 qint32 v = lookupValue(filePath);
298 bool ok =
_header.remove(v, e) > 0;
307 return lookupValue(filePath) >= 0;
314 qint32 v = lookupValue(filePath);
316 qWarning() <<
"LgpToc::renameEntry invalid filename" <<
filePath;
322 qWarning() <<
"LgpToc::renameEntry file not found" <<
filePath;
328 qint32 newV = lookupValue(newFilePath);
330 qWarning() <<
"LgpToc::renameEntry invalid new filename" << newFilePath;
334 if(entry(newFilePath, newV) != NULL) {
335 qWarning() <<
"LgpToc::renameEntry new file exists" << newFilePath;
341 if(
_header.remove(v, e) <= 0) {
342 qWarning() <<
"LgpToc::renameEntry cannot remove entry";
354 return entry(filePath) != NULL;
376 QMultiMap<quint32, const LgpHeaderEntry *> ret;
399 int index = filePath.lastIndexOf(
'/');
407 if(filePath.size() < index + 2) {
411 char c1 = lookupValue(filePath.at(index));
417 char c2 = lookupValue(filePath.at(index + 1));
428 char c = qc.toLower().toLatin1();
434 if(c >=
'0' && c <=
'9') {
438 if(c ==
'_') c =
'k';
439 if(c ==
'-') c =
'l';
bool removeEntry(const QString &filePath)
qint64 readData(char *data, qint64 maxSize)
const QMultiHash< quint16, LgpHeaderEntry * > & table() const
LgpToc & operator=(const LgpToc &other)
qint64 writeData(const char *data, qint64 maxSize)
You cannot write more than the initial file size.
static bool isNameValid(const QString &filePath)
QList< LgpHeaderEntry * > entries(quint16 id) const
LgpIO(QIODevice *lgp, const LgpHeaderEntry *header, QObject *parent=0)
bool addEntry(LgpHeaderEntry *entry)
bool renameEntry(const QString &filePath, const QString &newFilePath)
bool hasEntries(quint16 id) const
const QString & fileName() const
Returns the current file name (without the directory).
const LgpHeaderEntry * _header
QString filePath() const
Returns the current full file path (dir + name).
QList< const LgpHeaderEntry * > filesSortedByPosition() const
static qint32 lookupValue(const QString &filePath)
bool contains(const QString &filePath) const
LgpHeaderEntry * entry(const QString &filePath) const