mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
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
This commit is contained in:
parent
820517f340
commit
a763858080
5 changed files with 0 additions and 204 deletions
|
@ -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")
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
set(TARGET_NAME cache-extract)
|
||||
|
||||
setup_hifi_project()
|
||||
|
||||
link_hifi_libraries()
|
||||
copy_dlls_beside_windows_executable()
|
||||
|
|
@ -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 <QDebug>
|
||||
#include <QStandardPaths>
|
||||
#include <QDir>
|
||||
#include <QtNetwork/QAbstractNetworkCache>
|
||||
#include <QDataStream>
|
||||
|
||||
// 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<QString> 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;
|
||||
}
|
|
@ -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 <QtCore/QCoreApplication>
|
||||
#include <QtCore/QCommandLineParser>
|
||||
#include <QtNetwork/QNetworkDiskCache>
|
||||
#include <QBuffer>
|
||||
#include <QDateTime>
|
||||
#include <QtNetwork/QNetworkRequest>
|
||||
|
||||
// copy of QNetworkCacheMetaData
|
||||
class MyMetaData {
|
||||
public:
|
||||
using RawHeader = QPair<QByteArray, QByteArray>;
|
||||
using RawHeaderList = QList<RawHeader>;
|
||||
using AttributesMap = QHash<qint32, QVariant>;
|
||||
|
||||
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
|
|
@ -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 <QtCore/QCoreApplication>
|
||||
#include "CacheExtractApp.h"
|
||||
|
||||
int main (int argc, char** argv) {
|
||||
CacheExtractApp app(argc, argv);
|
||||
return app.exec();
|
||||
}
|
Loading…
Reference in a new issue