From a76385808041f4e6a3dc2b9576c242176bed9668 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Wed, 11 Nov 2015 11:22:05 -0800 Subject: [PATCH] Revert cache-extract This reverts these commits: * 82b26b7 Code convention fixes * 9a484ff Fixes for windows * 086b064 Dumps all urls extracted to stdout. * c002888 Added cache extractor to the tools directory --- tools/CMakeLists.txt | 3 - tools/cache-extract/CMakeLists.txt | 7 -- tools/cache-extract/src/CacheExtractApp.cpp | 130 -------------------- tools/cache-extract/src/CacheExtractApp.h | 47 ------- tools/cache-extract/src/main.cpp | 17 --- 5 files changed, 204 deletions(-) delete mode 100644 tools/cache-extract/CMakeLists.txt delete mode 100644 tools/cache-extract/src/CacheExtractApp.cpp delete mode 100644 tools/cache-extract/src/CacheExtractApp.h delete mode 100644 tools/cache-extract/src/main.cpp diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 9bc7031720..2056044a4b 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -10,6 +10,3 @@ set_target_properties(udt-test PROPERTIES FOLDER "Tools") add_subdirectory(vhacd-util) set_target_properties(vhacd-util PROPERTIES FOLDER "Tools") - -add_subdirectory(cache-extract) -set_target_properties(cache-extract PROPERTIES FOLDER "Tools") diff --git a/tools/cache-extract/CMakeLists.txt b/tools/cache-extract/CMakeLists.txt deleted file mode 100644 index 1aaa4d9d04..0000000000 --- a/tools/cache-extract/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -set(TARGET_NAME cache-extract) - -setup_hifi_project() - -link_hifi_libraries() -copy_dlls_beside_windows_executable() - diff --git a/tools/cache-extract/src/CacheExtractApp.cpp b/tools/cache-extract/src/CacheExtractApp.cpp deleted file mode 100644 index 0cfaef3f83..0000000000 --- a/tools/cache-extract/src/CacheExtractApp.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// -// CacheExtractApp.cpp -// tools/cache-extract/src -// -// Created by Anthony Thibault on 11/6/2015. -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "CacheExtractApp.h" -#include -#include -#include -#include -#include - -// extracted from qnetworkdiskcache.cpp -#define CACHE_VERSION 8 -enum { - CacheMagic = 0xe8, - CurrentCacheVersion = CACHE_VERSION -}; - -CacheExtractApp::CacheExtractApp(int& argc, char** argv) : - QCoreApplication(argc, argv) -{ - QString myDataLoc = QStandardPaths::writableLocation(QStandardPaths::DataLocation); - int lastSlash = myDataLoc.lastIndexOf("/"); - QString cachePath = myDataLoc.leftRef(lastSlash).toString() + "/" + - "High Fidelity" + "/" + "Interface" + "/" + - "data" + QString::number(CACHE_VERSION) + "/"; - - QString outputPath = myDataLoc.leftRef(lastSlash).toString() + "/" + - "High Fidelity" + "/" + "Interface" + "/" + "extracted"; - - qDebug() << "Searching cachePath = " << cachePath << "..."; - - // build list of files - QList fileList; - QDir dir(cachePath); - dir.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot); - QFileInfoList list = dir.entryInfoList(); - for (int i = 0; i < list.size(); ++i) { - QFileInfo fileInfo = list.at(i); - if (fileInfo.isDir()) { - QDir subDir(fileInfo.filePath()); - subDir.setFilter(QDir::Files); - QFileInfoList subList = subDir.entryInfoList(); - for (int j = 0; j < subList.size(); ++j) { - fileList << subList.at(j).filePath(); - } - } - } - - // dump each cache file into the outputPath - for (int i = 0; i < fileList.size(); ++i) { - QByteArray contents; - MyMetaData metaData; - if (extractFile(fileList.at(i), metaData, contents)) { - QString outFileName = outputPath + metaData.url.path(); - int lastSlash = outFileName.lastIndexOf("/"); - QString outDirName = outFileName.leftRef(lastSlash).toString(); - QDir dir; - dir.mkpath(outDirName); - QFile out(outFileName); - if (out.open(QIODevice::WriteOnly)) { - out.write(contents); - out.close(); - qDebug().noquote() << metaData.url.toDisplayString(); - } - else { - qCritical() << "Error opening outputFile = " << outFileName; - } - } else { - qCritical() << "Error extracting = " << fileList.at(i); - } - } - - QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection); -} - -bool CacheExtractApp::extractFile(const QString& filePath, MyMetaData& metaData, QByteArray& data) const { - QFile f(filePath); - if (!f.open(QIODevice::ReadOnly)) { - qDebug() << "error opening " << filePath; - return false; - } - QDataStream in(&f); - // from qnetworkdiskcache.cpp QCacheItem::read() - qint32 marker, version, streamVersion; - in >> marker; - if (marker != CacheMagic) { - return false; - } - in >> version; - if (version != CurrentCacheVersion) { - return false; - } - in >> streamVersion; - if (streamVersion > in.version()) - return false; - in.setVersion(streamVersion); - - bool compressed; - in >> metaData; - in >> compressed; - if (compressed) { - QByteArray compressedData; - in >> compressedData; - QBuffer buffer; - buffer.setData(qUncompress(compressedData)); - buffer.open(QBuffer::ReadOnly); - data = buffer.readAll(); - } else { - data = f.readAll(); - } - return true; -} - -QDataStream &operator>>(QDataStream& in, MyMetaData& metaData) { - in >> metaData.url; - in >> metaData.expirationDate; - in >> metaData.lastModified; - in >> metaData.saveToDisk; - in >> metaData.attributes; - in >> metaData.rawHeaders; - return in; -} diff --git a/tools/cache-extract/src/CacheExtractApp.h b/tools/cache-extract/src/CacheExtractApp.h deleted file mode 100644 index 3b34ff891d..0000000000 --- a/tools/cache-extract/src/CacheExtractApp.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// CacheExtractApp.h -// tools/cache-extract/src -// -// Created by Anthony Thibault on 11/6/2015 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#ifndef hifi_CacheExtractApp_h -#define hifi_CacheExtractApp_h - -#include -#include -#include -#include -#include -#include - -// copy of QNetworkCacheMetaData -class MyMetaData { -public: - using RawHeader = QPair; - using RawHeaderList = QList; - using AttributesMap = QHash; - - QUrl url; - QDateTime expirationDate; - QDateTime lastModified; - bool saveToDisk; - AttributesMap attributes; - RawHeaderList rawHeaders; -}; - -QDataStream &operator>>(QDataStream& in, MyMetaData& metaData); - -class CacheExtractApp : public QCoreApplication { - Q_OBJECT -public: - CacheExtractApp(int& argc, char** argv); - - bool extractFile(const QString& filePath, MyMetaData& metaData, QByteArray& data) const; -}; - -#endif // hifi_CacheExtractApp_h diff --git a/tools/cache-extract/src/main.cpp b/tools/cache-extract/src/main.cpp deleted file mode 100644 index 71a364ed3e..0000000000 --- a/tools/cache-extract/src/main.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// -// main.cpp -// tools/cache-extract/src -// -// Created by Anthony Thibault on 11/6/2015. -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html - -#include -#include "CacheExtractApp.h" - -int main (int argc, char** argv) { - CacheExtractApp app(argc, argv); - return app.exec(); -}