File indexing completed on 2024-12-01 05:20:02
0001 /* 0002 SPDX-FileCopyrightText: 2002 Szombathelyi György <gyurco@users.sourceforge.net> 0003 SPDX-FileCopyrightText: 2004-2022 Krusader Krew <https://krusader.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "kisofile.h" 0009 0010 KIsoFile::KIsoFile(KArchive *archive, 0011 const QString &name, 0012 int access, 0013 time_t date, 0014 time_t adate, 0015 time_t cdate, 0016 const QString &user, 0017 const QString &group, 0018 const QString &symlink, 0019 long long pos, 0020 long long size) 0021 : KArchiveFile(archive, name, access, QDateTime::fromTime_t(static_cast<uint>(date)), user, group, symlink, pos, size) 0022 { 0023 m_adate = adate; 0024 m_cdate = cdate; 0025 m_algo[0] = 0; 0026 m_algo[1] = 0; 0027 m_parms[0] = 0; 0028 m_parms[1] = 0; 0029 m_realsize = 0; 0030 } 0031 0032 KIsoFile::~KIsoFile() = default; 0033 0034 void KIsoFile::setZF(char algo[2], char parms[2], long long realsize) 0035 { 0036 m_algo[0] = algo[0]; 0037 m_algo[1] = algo[1]; 0038 m_parms[0] = parms[0]; 0039 m_parms[1] = parms[1]; 0040 m_realsize = realsize; 0041 } 0042 0043 QByteArray KIsoFile::dataAt(long long pos, long long count) const 0044 { 0045 QByteArray r; 0046 qint64 rlen; 0047 0048 if (archive()->device()->seek(position() + pos)) { 0049 r.resize(static_cast<int>(((pos + count) < size()) ? count : size() - pos)); 0050 if (r.size()) { 0051 rlen = archive()->device()->read(r.data(), r.size()); 0052 if (rlen == -1) 0053 r.resize(0); 0054 else if (rlen != (int)r.size()) 0055 r.resize(static_cast<int>(rlen)); 0056 } 0057 } 0058 0059 return r; 0060 }