From 8cab40c136525e73437768f3307e92339dc4c992 Mon Sep 17 00:00:00 2001 From: "Jesper K. Pedersen" Date: Mon, 20 May 2013 13:09:46 +0200 Subject: added a copyFile for script Change-Id: I448a92119f58f41c290b0189e97895c5ec1a117f Reviewed-by: Nicolas Arnaud-Cormos --- utils/utils.cpp | 20 ++++++++++++++++++++ utils/utils.h | 1 + 2 files changed, 21 insertions(+) diff --git a/utils/utils.cpp b/utils/utils.cpp index f6adfcd..9cb341a 100644 --- a/utils/utils.cpp +++ b/utils/utils.cpp @@ -30,6 +30,7 @@ #include "utils.h" #include #include "scriptrunner.h" +#include namespace Scripting { namespace Internal { @@ -55,6 +56,25 @@ QString Utils::currentScripRoot() const return ScriptRunner::currentScriptRoot(); } +bool Scripting::Internal::Utils::copyFile(const QString &from, const QString &to) +{ + QFile fromFile(from); + if ( !fromFile.open(QFile::ReadOnly)) { + return false; + } + + QFile toFile(to); + if (!toFile.open(QFile::WriteOnly)) { + return false; + } + + QByteArray content = fromFile.readAll(); + toFile.write(content); + fromFile.close(); + toFile.close(); + return true; +} + } // namespace Internal } // namespace Scripting diff --git a/utils/utils.h b/utils/utils.h index 517544e..e6f8655 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -45,6 +45,7 @@ public: public slots: QStringList backtrace() const; + bool copyFile(const QString& from, const QString& to); public: QString currentScripRoot() const; -- cgit v1.2.3