Changeset View
Changeset View
Standalone View
Standalone View
iso/iso.cpp
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | |||||
72 | static const unsigned char zisofs_magic[8] = { | 72 | static const unsigned char zisofs_magic[8] = { | ||
73 | 0x37, 0xE4, 0x53, 0x96, 0xC9, 0xDB, 0xD6, 0x07 | 73 | 0x37, 0xE4, 0x53, 0x96, 0xC9, 0xDB, 0xD6, 0x07 | ||
74 | }; | 74 | }; | ||
75 | 75 | | |||
76 | 76 | | |||
77 | kio_isoProtocol::kio_isoProtocol(const QByteArray &pool, const QByteArray &app) : SlaveBase("iso", pool, app) | 77 | kio_isoProtocol::kio_isoProtocol(const QByteArray &pool, const QByteArray &app) : SlaveBase("iso", pool, app) | ||
78 | { | 78 | { | ||
79 | //qDebug() << "kio_isoProtocol::kio_isoProtocol" << endl; | 79 | //qDebug() << "kio_isoProtocol::kio_isoProtocol" << endl; | ||
80 | m_isoFile = 0L; | 80 | m_isoFile = nullptr; | ||
81 | } | 81 | } | ||
82 | 82 | | |||
83 | kio_isoProtocol::~kio_isoProtocol() | 83 | kio_isoProtocol::~kio_isoProtocol() | ||
84 | { | 84 | { | ||
85 | delete m_isoFile; | 85 | delete m_isoFile; | ||
86 | } | 86 | } | ||
87 | 87 | | |||
88 | bool kio_isoProtocol::checkNewFile(QString fullPath, QString & path, int startsec) | 88 | bool kio_isoProtocol::checkNewFile(QString fullPath, QString & path, int startsec) | ||
Show All 21 Lines | 94 | if (m_isoFile && startsec == m_isoFile->startSec() && | |||
110 | } | 110 | } | ||
111 | } | 111 | } | ||
112 | //qDebug() << "Need to open a new file" << endl; | 112 | //qDebug() << "Need to open a new file" << endl; | ||
113 | 113 | | |||
114 | // Close previous file | 114 | // Close previous file | ||
115 | if (m_isoFile) { | 115 | if (m_isoFile) { | ||
116 | m_isoFile->close(); | 116 | m_isoFile->close(); | ||
117 | delete m_isoFile; | 117 | delete m_isoFile; | ||
118 | m_isoFile = 0L; | 118 | m_isoFile = nullptr; | ||
119 | } | 119 | } | ||
120 | 120 | | |||
121 | // Find where the iso file is in the full path | 121 | // Find where the iso file is in the full path | ||
122 | int pos = 0; | 122 | int pos = 0; | ||
123 | QString isoFile; | 123 | QString isoFile; | ||
124 | path.clear(); | 124 | path.clear(); | ||
125 | 125 | | |||
126 | int len = fullPath.length(); | 126 | int len = fullPath.length(); | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
169 | 169 | | |||
170 | // Open new file | 170 | // Open new file | ||
171 | //qDebug() << "Opening KIso on " << isoFile << endl; | 171 | //qDebug() << "Opening KIso on " << isoFile << endl; | ||
172 | m_isoFile = new KIso(isoFile); | 172 | m_isoFile = new KIso(isoFile); | ||
173 | m_isoFile->setStartSec(startsec); | 173 | m_isoFile->setStartSec(startsec); | ||
174 | if (!m_isoFile->open(QIODevice::ReadOnly)) { | 174 | if (!m_isoFile->open(QIODevice::ReadOnly)) { | ||
175 | //qDebug() << "Opening " << isoFile << " failed." << endl; | 175 | //qDebug() << "Opening " << isoFile << " failed." << endl; | ||
176 | delete m_isoFile; | 176 | delete m_isoFile; | ||
177 | m_isoFile = 0L; | 177 | m_isoFile = nullptr; | ||
178 | return false; | 178 | return false; | ||
179 | } | 179 | } | ||
180 | 180 | | |||
181 | return true; | 181 | return true; | ||
182 | } | 182 | } | ||
183 | 183 | | |||
184 | 184 | | |||
185 | void kio_isoProtocol::createUDSEntry(const KArchiveEntry * isoEntry, UDSEntry & entry) | 185 | void kio_isoProtocol::createUDSEntry(const KArchiveEntry * isoEntry, UDSEntry & entry) | ||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | 219 | if (!checkNewFile(getPath(url), path, url.hasFragment() ? url.fragment(QUrl::FullyDecoded).toInt() : -1)) { | |||
229 | redir.setPath(getPath(url)); | 229 | redir.setPath(getPath(url)); | ||
230 | if (url.hasFragment()) redir.setFragment(url.fragment(QUrl::FullyDecoded)); | 230 | if (url.hasFragment()) redir.setFragment(url.fragment(QUrl::FullyDecoded)); | ||
231 | //qDebug() << "Ok, redirection to " << redir.url() << endl; | 231 | //qDebug() << "Ok, redirection to " << redir.url() << endl; | ||
232 | redir.setScheme("file"); | 232 | redir.setScheme("file"); | ||
233 | redirection(redir); | 233 | redirection(redir); | ||
234 | finished(); | 234 | finished(); | ||
235 | // And let go of the iso file - for people who want to unmount a cdrom after that | 235 | // And let go of the iso file - for people who want to unmount a cdrom after that | ||
236 | delete m_isoFile; | 236 | delete m_isoFile; | ||
237 | m_isoFile = 0L; | 237 | m_isoFile = nullptr; | ||
238 | return; | 238 | return; | ||
239 | } | 239 | } | ||
240 | 240 | | |||
241 | if (path.isEmpty()) { | 241 | if (path.isEmpty()) { | ||
242 | QUrl redir(QStringLiteral("iso:/")); | 242 | QUrl redir(QStringLiteral("iso:/")); | ||
243 | //qDebug() << "url.path()==" << getPath(url) << endl; | 243 | //qDebug() << "url.path()==" << getPath(url) << endl; | ||
244 | if (url.hasFragment()) redir.setFragment(url.fragment(QUrl::FullyDecoded)); | 244 | if (url.hasFragment()) redir.setFragment(url.fragment(QUrl::FullyDecoded)); | ||
245 | redir.setPath(getPath(url) + QString::fromLatin1(DIR_SEPARATOR)); | 245 | redir.setPath(getPath(url) + QString::fromLatin1(DIR_SEPARATOR)); | ||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | 296 | if (!checkNewFile(getPath(url), path, url.hasFragment() ? url.fragment(QUrl::FullyDecoded).toInt() : -1)) { | |||
311 | entry.insert(UDSEntry::UDS_FILE_TYPE, buff.st_mode & S_IFMT); | 311 | entry.insert(UDSEntry::UDS_FILE_TYPE, buff.st_mode & S_IFMT); | ||
312 | 312 | | |||
313 | statEntry(entry); | 313 | statEntry(entry); | ||
314 | 314 | | |||
315 | finished(); | 315 | finished(); | ||
316 | 316 | | |||
317 | // And let go of the iso file - for people who want to unmount a cdrom after that | 317 | // And let go of the iso file - for people who want to unmount a cdrom after that | ||
318 | delete m_isoFile; | 318 | delete m_isoFile; | ||
319 | m_isoFile = 0L; | 319 | m_isoFile = nullptr; | ||
320 | return; | 320 | return; | ||
321 | } | 321 | } | ||
322 | 322 | | |||
323 | const KArchiveDirectory* root = m_isoFile->directory(); | 323 | const KArchiveDirectory* root = m_isoFile->directory(); | ||
324 | const KArchiveEntry* isoEntry; | 324 | const KArchiveEntry* isoEntry; | ||
325 | if (path.isEmpty()) { | 325 | if (path.isEmpty()) { | ||
326 | path = QString::fromLatin1(DIR_SEPARATOR); | 326 | path = QString::fromLatin1(DIR_SEPARATOR); | ||
327 | isoEntry = root; | 327 | isoEntry = root; | ||
Show All 9 Lines | |||||
337 | finished(); | 337 | finished(); | ||
338 | } | 338 | } | ||
339 | 339 | | |||
340 | void kio_isoProtocol::getFile(const KIsoFile *isoFileEntry, const QString &path) | 340 | void kio_isoProtocol::getFile(const KIsoFile *isoFileEntry, const QString &path) | ||
341 | { | 341 | { | ||
342 | unsigned long long size, pos = 0; | 342 | unsigned long long size, pos = 0; | ||
343 | bool mime = false, zlib = false; | 343 | bool mime = false, zlib = false; | ||
344 | QByteArray fileData, pointer_block, inbuf, outbuf; | 344 | QByteArray fileData, pointer_block, inbuf, outbuf; | ||
345 | char *pptr = 0; | 345 | char *pptr = nullptr; | ||
346 | compressed_file_header *hdr; | 346 | compressed_file_header *hdr; | ||
347 | int block_shift; | 347 | int block_shift; | ||
348 | unsigned long nblocks; | 348 | unsigned long nblocks; | ||
349 | unsigned long fullsize = 0, block_size = 0, block_size2 = 0; | 349 | unsigned long fullsize = 0, block_size = 0, block_size2 = 0; | ||
350 | size_t ptrblock_bytes; | 350 | size_t ptrblock_bytes; | ||
351 | unsigned long cstart, cend, csize; | 351 | unsigned long cstart, cend, csize; | ||
352 | uLong bytes; | 352 | uLong bytes; | ||
353 | 353 | | |||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Line(s) | 486 | if (!isoEntry) { | |||
487 | error(KIO::ERR_DOES_NOT_EXIST, path); | 487 | error(KIO::ERR_DOES_NOT_EXIST, path); | ||
488 | return; | 488 | return; | ||
489 | } | 489 | } | ||
490 | if (isoEntry->isDirectory()) { | 490 | if (isoEntry->isDirectory()) { | ||
491 | error(KIO::ERR_IS_DIRECTORY, path); | 491 | error(KIO::ERR_IS_DIRECTORY, path); | ||
492 | return; | 492 | return; | ||
493 | } | 493 | } | ||
494 | 494 | | |||
495 | const KIsoFile* isoFileEntry = static_cast<const KIsoFile *>(isoEntry); | 495 | const auto* isoFileEntry = dynamic_cast<const KIsoFile *>(isoEntry); | ||
496 | if (!isoEntry->symLinkTarget().isEmpty()) { | 496 | if (!isoEntry->symLinkTarget().isEmpty()) { | ||
497 | //qDebug() << "Redirection to " << isoEntry->symLinkTarget() << endl; | 497 | //qDebug() << "Redirection to " << isoEntry->symLinkTarget() << endl; | ||
498 | QUrl realURL = QUrl(url).resolved(QUrl(isoEntry->symLinkTarget())); | 498 | QUrl realURL = QUrl(url).resolved(QUrl(isoEntry->symLinkTarget())); | ||
499 | //qDebug() << "realURL= " << realURL.url() << endl; | 499 | //qDebug() << "realURL= " << realURL.url() << endl; | ||
500 | realURL.setScheme("file"); | 500 | realURL.setScheme("file"); | ||
501 | redirection(realURL); | 501 | redirection(realURL); | ||
502 | finished(); | 502 | finished(); | ||
503 | return; | 503 | return; | ||
Show All 23 Lines |