diff options
-rw-r--r-- | rbutil/rbutilqt/base/utils.cpp | 31 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/utils.h | 4 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/zipinstaller.cpp | 3 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/ziputil.cpp | 21 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/ziputil.h | 2 |
5 files changed, 51 insertions, 10 deletions
diff --git a/rbutil/rbutilqt/base/utils.cpp b/rbutil/rbutilqt/base/utils.cpp index 1fdf627378..ca3a6d2256 100644 --- a/rbutil/rbutilqt/base/utils.cpp +++ b/rbutil/rbutilqt/base/utils.cpp | |||
@@ -187,13 +187,25 @@ QString Utils::filesystemName(QString path) | |||
187 | //! @return size in bytes | 187 | //! @return size in bytes |
188 | qulonglong Utils::filesystemFree(QString path) | 188 | qulonglong Utils::filesystemFree(QString path) |
189 | { | 189 | { |
190 | return filesystemSize(path, FilesystemFree); | 190 | qulonglong size = filesystemSize(path, FilesystemFree); |
191 | qDebug() << "[Utils] free disk space for" << path << size; | ||
192 | return size; | ||
191 | } | 193 | } |
192 | 194 | ||
193 | 195 | ||
194 | qulonglong Utils::filesystemTotal(QString path) | 196 | qulonglong Utils::filesystemTotal(QString path) |
195 | { | 197 | { |
196 | return filesystemSize(path, FilesystemTotal); | 198 | qulonglong size = filesystemSize(path, FilesystemTotal); |
199 | qDebug() << "[Utils] total disk space for" << path << size; | ||
200 | return size; | ||
201 | } | ||
202 | |||
203 | |||
204 | qulonglong Utils::filesystemClusterSize(QString path) | ||
205 | { | ||
206 | qulonglong size = filesystemSize(path, FilesystemClusterSize); | ||
207 | qDebug() << "[Utils] cluster size for" << path << size; | ||
208 | return size; | ||
197 | } | 209 | } |
198 | 210 | ||
199 | 211 | ||
@@ -214,6 +226,9 @@ qulonglong Utils::filesystemSize(QString path, enum Utils::Size type) | |||
214 | if(type == FilesystemTotal) { | 226 | if(type == FilesystemTotal) { |
215 | size = (qulonglong)fs.f_frsize * (qulonglong)fs.f_blocks; | 227 | size = (qulonglong)fs.f_frsize * (qulonglong)fs.f_blocks; |
216 | } | 228 | } |
229 | if(type == FilesystemClusterSize) { | ||
230 | size = (qulonglong)fs.f_frsize; | ||
231 | } | ||
217 | } | 232 | } |
218 | #endif | 233 | #endif |
219 | #if defined(Q_OS_WIN32) | 234 | #if defined(Q_OS_WIN32) |
@@ -230,9 +245,19 @@ qulonglong Utils::filesystemSize(QString path, enum Utils::Size type) | |||
230 | if(type == FilesystemTotal) { | 245 | if(type == FilesystemTotal) { |
231 | size = totalNumberBytes.QuadPart; | 246 | size = totalNumberBytes.QuadPart; |
232 | } | 247 | } |
248 | if(type == FilesystemClusterSize) { | ||
249 | DWORD sectorsPerCluster; | ||
250 | DWORD bytesPerSector; | ||
251 | DWORD freeClusters; | ||
252 | DWORD totalClusters; | ||
253 | ret = GetDiskFreeSpaceW((LPCTSTR)path.utf16(), §orsPerCluster, | ||
254 | &bytesPerSector, &freeClusters, &totalClusters); | ||
255 | if(ret) { | ||
256 | size = bytesPerSector * sectorsPerCluster; | ||
257 | } | ||
258 | } | ||
233 | } | 259 | } |
234 | #endif | 260 | #endif |
235 | qDebug() << "[Utils] Filesystem:" << path << size; | ||
236 | return size; | 261 | return size; |
237 | } | 262 | } |
238 | 263 | ||
diff --git a/rbutil/rbutilqt/base/utils.h b/rbutil/rbutilqt/base/utils.h index 659bbc4ed4..b4477699fd 100644 --- a/rbutil/rbutilqt/base/utils.h +++ b/rbutil/rbutilqt/base/utils.h | |||
@@ -33,13 +33,15 @@ class Utils : public QObject | |||
33 | public: | 33 | public: |
34 | enum Size { | 34 | enum Size { |
35 | FilesystemTotal, | 35 | FilesystemTotal, |
36 | FilesystemFree | 36 | FilesystemFree, |
37 | FilesystemClusterSize, | ||
37 | }; | 38 | }; |
38 | 39 | ||
39 | static bool recursiveRmdir(const QString &dirName); | 40 | static bool recursiveRmdir(const QString &dirName); |
40 | static QString resolvePathCase(QString path); | 41 | static QString resolvePathCase(QString path); |
41 | static qulonglong filesystemFree(QString path); | 42 | static qulonglong filesystemFree(QString path); |
42 | static qulonglong filesystemTotal(QString path); | 43 | static qulonglong filesystemTotal(QString path); |
44 | static qulonglong filesystemClusterSize(QString path); | ||
43 | static qulonglong filesystemSize(QString path, enum Size type); | 45 | static qulonglong filesystemSize(QString path, enum Size type); |
44 | static QString findExecutable(QString name); | 46 | static QString findExecutable(QString name); |
45 | static QString checkEnvironment(bool permission); | 47 | static QString checkEnvironment(bool permission); |
diff --git a/rbutil/rbutilqt/base/zipinstaller.cpp b/rbutil/rbutilqt/base/zipinstaller.cpp index 76f673ff81..c450f3015f 100644 --- a/rbutil/rbutilqt/base/zipinstaller.cpp +++ b/rbutil/rbutilqt/base/zipinstaller.cpp | |||
@@ -140,7 +140,8 @@ void ZipInstaller::downloadDone(bool error) | |||
140 | // some room for operating (also includes calculation mistakes due to | 140 | // some room for operating (also includes calculation mistakes due to |
141 | // cluster sizes on the player). | 141 | // cluster sizes on the player). |
142 | if((qint64)Utils::filesystemFree(m_mountpoint) | 142 | if((qint64)Utils::filesystemFree(m_mountpoint) |
143 | < (zip.totalUncompressedSize() + 1000000)) { | 143 | < (zip.totalUncompressedSize(Utils::filesystemClusterSize(m_mountpoint)) |
144 | + 1000000)) { | ||
144 | emit logItem(tr("Not enough disk space! Aborting."), LOGERROR); | 145 | emit logItem(tr("Not enough disk space! Aborting."), LOGERROR); |
145 | emit logProgress(1, 1); | 146 | emit logProgress(1, 1); |
146 | emit done(true); | 147 | emit done(true); |
diff --git a/rbutil/rbutilqt/base/ziputil.cpp b/rbutil/rbutilqt/base/ziputil.cpp index ed8f17eefe..4396fa5e87 100644 --- a/rbutil/rbutilqt/base/ziputil.cpp +++ b/rbutil/rbutilqt/base/ziputil.cpp | |||
@@ -205,7 +205,7 @@ bool ZipUtil::appendFileToArchive(QString& file, QString& basedir) | |||
205 | 205 | ||
206 | 206 | ||
207 | //! @brief calculate total size of extracted files | 207 | //! @brief calculate total size of extracted files |
208 | qint64 ZipUtil::totalUncompressedSize(void) | 208 | qint64 ZipUtil::totalUncompressedSize(unsigned int clustersize) |
209 | { | 209 | { |
210 | qint64 uncompressed = 0; | 210 | qint64 uncompressed = 0; |
211 | 211 | ||
@@ -214,10 +214,23 @@ qint64 ZipUtil::totalUncompressedSize(void) | |||
214 | return -1; | 214 | return -1; |
215 | } | 215 | } |
216 | int max = items.size(); | 216 | int max = items.size(); |
217 | for(int i = 0; i < max; ++i) { | 217 | if(clustersize > 0) { |
218 | uncompressed += items.at(i).uncompressedSize; | 218 | for(int i = 0; i < max; ++i) { |
219 | qint64 item = items.at(i).uncompressedSize; | ||
220 | uncompressed += (item + clustersize - (item % clustersize)); | ||
221 | } | ||
222 | } | ||
223 | else { | ||
224 | for(int i = 0; i < max; ++i) { | ||
225 | uncompressed += items.at(i).uncompressedSize; | ||
226 | } | ||
227 | } | ||
228 | if(clustersize > 0) { | ||
229 | qDebug() << "[ZipUtil] calculation rounded to cluster size for each file:" | ||
230 | << clustersize; | ||
219 | } | 231 | } |
220 | qDebug() << "[ZipUtil] size of archive files uncompressed:" << uncompressed; | 232 | qDebug() << "[ZipUtil] size of archive files uncompressed:" |
233 | << uncompressed; | ||
221 | return uncompressed; | 234 | return uncompressed; |
222 | } | 235 | } |
223 | 236 | ||
diff --git a/rbutil/rbutilqt/base/ziputil.h b/rbutil/rbutilqt/base/ziputil.h index cfafb96566..dc1b986c29 100644 --- a/rbutil/rbutilqt/base/ziputil.h +++ b/rbutil/rbutilqt/base/ziputil.h | |||
@@ -37,7 +37,7 @@ class ZipUtil : public QObject | |||
37 | bool extractArchive(QString& dest); | 37 | bool extractArchive(QString& dest); |
38 | bool appendDirToArchive(QString& source, QString& basedir); | 38 | bool appendDirToArchive(QString& source, QString& basedir); |
39 | bool appendFileToArchive(QString& file, QString& basedir); | 39 | bool appendFileToArchive(QString& file, QString& basedir); |
40 | qint64 totalUncompressedSize(void); | 40 | qint64 totalUncompressedSize(unsigned int clustersize = 0); |
41 | QStringList files(void); | 41 | QStringList files(void); |
42 | 42 | ||
43 | signals: | 43 | signals: |