|
|
@ -37,21 +37,34 @@ using namespace dev; |
|
|
|
using namespace dev::crypto; |
|
|
|
using namespace dev::mix; |
|
|
|
|
|
|
|
void FileIo::makeDir(QString const& _url) |
|
|
|
QString FileIo::pathFromUrl(QString const& _url) |
|
|
|
{ |
|
|
|
QUrl url(_url); |
|
|
|
QDir dirPath(url.path()); |
|
|
|
QString path(url.path()); |
|
|
|
if (url.scheme() == "qrc") |
|
|
|
path = ":" + path; |
|
|
|
#ifdef WIN32 |
|
|
|
if (url.scheme() == "file") |
|
|
|
{ |
|
|
|
if (path.startsWith("/")) |
|
|
|
path = path.right(path.length() - 1); |
|
|
|
if (!url.host().isEmpty()) |
|
|
|
path = url.host() + ":/" + path; |
|
|
|
} |
|
|
|
#endif |
|
|
|
return path; |
|
|
|
} |
|
|
|
|
|
|
|
void FileIo::makeDir(QString const& _url) |
|
|
|
{ |
|
|
|
QDir dirPath(pathFromUrl(_url)); |
|
|
|
if (!dirPath.exists()) |
|
|
|
dirPath.mkpath(dirPath.path()); |
|
|
|
} |
|
|
|
|
|
|
|
QString FileIo::readFile(QString const& _url) |
|
|
|
{ |
|
|
|
QUrl url(_url); |
|
|
|
QString path(url.path()); |
|
|
|
if (url.scheme() == "qrc") |
|
|
|
path = ":" + path; |
|
|
|
QFile file(path); |
|
|
|
QFile file(pathFromUrl(_url)); |
|
|
|
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) |
|
|
|
{ |
|
|
|
QTextStream stream(&file); |
|
|
@ -65,8 +78,7 @@ QString FileIo::readFile(QString const& _url) |
|
|
|
|
|
|
|
void FileIo::writeFile(QString const& _url, QString const& _data) |
|
|
|
{ |
|
|
|
QUrl url(_url); |
|
|
|
QFile file(url.path()); |
|
|
|
QFile file(pathFromUrl(_url)); |
|
|
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) |
|
|
|
{ |
|
|
|
QTextStream stream(&file); |
|
|
@ -84,9 +96,7 @@ void FileIo::copyFile(QString const& _sourceUrl, QString const& _destUrl) |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
QUrl sourceUrl(_sourceUrl); |
|
|
|
QUrl destUrl(_destUrl); |
|
|
|
if (!QFile::copy(sourceUrl.path(), destUrl.path())) |
|
|
|
if (!QFile::copy(pathFromUrl(_sourceUrl), pathFromUrl(_destUrl))) |
|
|
|
error(tr("Error copying file %1 to %2").arg(_sourceUrl).arg(_destUrl)); |
|
|
|
} |
|
|
|
|
|
|
@ -97,29 +107,22 @@ QString FileIo::getHomePath() const |
|
|
|
|
|
|
|
void FileIo::moveFile(QString const& _sourceUrl, QString const& _destUrl) |
|
|
|
{ |
|
|
|
QUrl sourceUrl(_sourceUrl); |
|
|
|
QUrl destUrl(_destUrl); |
|
|
|
if (!QFile::rename(sourceUrl.path(), destUrl.path())) |
|
|
|
if (!QFile::rename(pathFromUrl(_sourceUrl), pathFromUrl(_destUrl))) |
|
|
|
error(tr("Error moving file %1 to %2").arg(_sourceUrl).arg(_destUrl)); |
|
|
|
} |
|
|
|
|
|
|
|
bool FileIo::fileExists(QString const& _url) |
|
|
|
{ |
|
|
|
QUrl url(_url); |
|
|
|
QFile file(url.path()); |
|
|
|
QFile file(pathFromUrl(_url)); |
|
|
|
return file.exists(); |
|
|
|
} |
|
|
|
|
|
|
|
QStringList FileIo::makePackage(QString const& _deploymentFolder) |
|
|
|
{ |
|
|
|
|
|
|
|
Json::Value manifest; |
|
|
|
Json::Value entries(Json::arrayValue); |
|
|
|
|
|
|
|
QUrl folder(_deploymentFolder); |
|
|
|
QString path(folder.path()); |
|
|
|
QDir deployDir = QDir(path); |
|
|
|
|
|
|
|
QDir deployDir = QDir(pathFromUrl(_deploymentFolder)); |
|
|
|
dev::RLPStream rlpStr; |
|
|
|
int k = 1; |
|
|
|
std::vector<bytes> files; |
|
|
|