FU Logo
  • Startseite
  • Kontakt
  • Impressum
  • Home
  • Listenauswahl
  • Anleitungen

[linux-minidisc] [PATCH 2/3] Changed download directory to temp

<-- thread -->
<-- date -->
  • From: Philipp Neuser <pneuser@physik.fu-berlin.de>
  • To: linux-minidisc@lists.fu-berlin.de
  • Date: Sat, 20 Mar 2010 14:38:02 +0100
  • Subject: [linux-minidisc] [PATCH 2/3] Changed download directory to temp

---
 inet-updater/update.cpp |   13 +++++++++----
 inet-updater/update.h   |    1 +
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/inet-updater/update.cpp b/inet-updater/update.cpp
index dfd02bd..a979f86 100644
--- a/inet-updater/update.cpp
+++ b/inet-updater/update.cpp
@@ -5,6 +5,9 @@
 #include <QHttp>
 #include <QUrl>
 #include <QProcess>
+#include <stdlib.h>
+#include <QDebug>
+
 
 Update::Update(QWidget *parent) :
     QMainWindow(parent),
@@ -12,6 +15,7 @@ Update::Update(QWidget *parent) :
 {
     //ui->pushButton->setEnabled(false);
 
+    temp = getenv("TEMP");
     ui->setupUi(this);
     checkForUpdate();
 
@@ -63,7 +67,8 @@ void Update::checkForUpdate(){
             QUrl url(conf["ver-url"]);
             http->setHost(url.host());
 
-            down_fp =  new QFile("updater-new.txt");
+            down_fp =  new QFile(temp+"\\updater-new.txt");
+            //QMessageBox::warning(this, "Test",temp+"\\updater-new.txt");
             if(down_fp->open(QIODevice::WriteOnly)){
                 id_phase = http->get(url.path(),down_fp);
             }else{
@@ -122,7 +127,7 @@ void Update::downloaded(bool error){
         down_fp->close();
         //start reading the new updater.txt from the internet an compare versions
         QString cline;
-        QFile newconf("updater-new.txt");
+        QFile newconf(temp+"\\updater-new.txt");
         if(newconf.open(QIODevice::ReadOnly | QIODevice::Text)){
             while(!newconf.atEnd()){
                 cline = newconf.readLine();
@@ -162,7 +167,7 @@ void Update::downloaded(bool error){
     if(down_phase=="update" && !error){
         down_fp->close();
         http->close();
-        QProcess::startDetached(conf["exec-update"]);
+        QProcess::startDetached(conf["exec-update"].replace("%DOWNLOAD-FILE-NAME%",temp+"\\"+conf["download-file-name"]),QStringList(),temp);
         //QMessageBox::warning(this,"IOError",conf["exec-update"]);
         down_phase="ready";
         this->close();
@@ -181,7 +186,7 @@ void Update::downloaded(bool error){
 void Update::do_update(){
     QUrl url(conf["download-url"]);
     down_phase="update";
-    down_fp = new QFile(conf["download-file-name"]);
+    down_fp = new QFile(temp+"\\"+conf["download-file-name"]);
     http->setHost(url.host());
     if(down_fp->open(QIODevice::WriteOnly)){
         http->get(url.path(),down_fp);
diff --git a/inet-updater/update.h b/inet-updater/update.h
index c70f51c..88ca7cd 100644
--- a/inet-updater/update.h
+++ b/inet-updater/update.h
@@ -27,6 +27,7 @@ private:
     int id_phase;
     QHttp* http;
     QFile* down_fp;
+    QString temp;
 public slots:
     void setProgress(int done, int total);
     void downloaded(bool);
-- 
1.7.0.2.msysgit.0




<-- thread -->
<-- date -->
  • References:
    • [linux-minidisc] [PATCH 1/3] This patch enables a self-update of qhimd-transfer via internet. You can configure the update files (installer file etc.) in the updater.txt. A sample config is here:
      • From: Philipp Neuser <pneuser@physik.fu-berlin.de>
  • linux-minidisc - March 2010 - Archives indexes sorted by:
    [ thread ] [ subject ] [ author ] [ date ]
  • Complete archive of the linux-minidisc mailing list
  • More info on this list...

Hilfe

  • FAQ
  • Dienstbeschreibung
  • ZEDAT Beratung
  • postmaster@lists.fu-berlin.de

Service-Navigation

  • Startseite
  • Listenauswahl

Einrichtung Mailingliste

  • ZEDAT-Portal
  • Mailinglisten Portal