Skip to content

Commit 41dc7ad

Browse files
committed
Back out open file from zip changes since they don't seem to work by double-clicking a filename in the zip. Works fine if set as a debug argument.
1 parent 95b9279 commit 41dc7ad

File tree

1 file changed

+5
-86
lines changed

1 file changed

+5
-86
lines changed

propside/mainspin.cpp

Lines changed: 5 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#include <QtGui>
22
#include "mainspinwindow.h"
3-
#include "quazip.h"
4-
#include "quazipfile.h"
5-
#include "directory.h"
63

74
int main(int argc, char *argv[])
85
{
@@ -59,89 +56,11 @@ int main(int argc, char *argv[])
5956

6057
if(argc > 1) {
6158
QString s = QString(argv[1]);
62-
if(s.contains(".zip",Qt::CaseInsensitive)) {
63-
int rc;
64-
QString sname = s;
65-
QRegExp rz(".zip", Qt::CaseInsensitive);
66-
int end = sname.lastIndexOf(rz);
67-
end += 4;
68-
QString zipname = s.mid(end+1);
69-
zipname = zipname.trimmed();
70-
sname = sname.mid(0,end);
71-
QuaZip zip(sname);
72-
zip.open(QuaZip::mdUnzip);
73-
rc = zip.getZipError();
74-
if(rc | (zipname.length() == 0) ) {
75-
QMessageBox::critical(&w, w.tr("Cannot Open from Zip"),
76-
w.tr("The file is in a zipped archive. Unzip to")+"\n"+
77-
w.tr("a folder first, and open from there instead."));
78-
}
79-
else {
80-
QStringList files = zip.getFileNameList();
81-
QString tmpfolder = QDir::tempPath()+"/SimpleIDE";
82-
if(files.count() > 0) {
83-
QDir dir(tmpfolder);
84-
if(QFile::exists(tmpfolder))
85-
Directory::recursiveRemoveDir(tmpfolder);
86-
dir.mkdir(tmpfolder);
87-
}
88-
#if 0
89-
foreach (QString file, files) {
90-
zip.getCurrentFileName(file);
91-
}
92-
#endif
93-
QuaZipFile file(&zip);
94-
bool f =zip.goToFirstFile();
95-
for(; f; f=zip.goToNextFile()) {
96-
QuaZipFileInfo info;
97-
file.getFileInfo(&info);
98-
if(info.name.length() == 0)
99-
continue;
100-
QString name = info.name;
101-
QStringList folders = name.split("/");
102-
103-
QString path = tmpfolder;
104-
for (int n = 0; n < folders.count()-1; n++) {
105-
path += "/" + folders[n];
106-
QDir dir(path);
107-
if(QFile::exists(path) == false)
108-
dir.mkdir(path);
109-
}
110-
111-
QFile newFile(tmpfolder+"/"+info.name);
112-
file.open(QIODevice::ReadOnly);
113-
newFile.open(QIODevice::WriteOnly);
114-
QTextStream outToFile(&newFile);
115-
outToFile << file.readAll();;
116-
newFile.close();
117-
file.close();
118-
}
119-
zip.close();
120-
121-
w.closeProject();
122-
QString filename = tmpfolder+"/"+zipname;
123-
if(filename.endsWith(".c") ||
124-
filename.endsWith(".cpp") ||
125-
filename.endsWith(".cogc") ||
126-
filename.endsWith(".h") ||
127-
filename.endsWith(".spin")) {
128-
w.openFile(tmpfolder+"/"+zipname);
129-
}
130-
/*
131-
* Disallow .side projects or other file names for now.
132-
*/
133-
else if (filename.endsWith(".side")) {
134-
QMessageBox::critical(&w, w.tr("Cannot Open Projects from Zip"),
135-
w.tr("The project is in a zipped archive. Unzip to")+"\n"+
136-
w.tr("a folder first, and open from there instead."));
137-
}
138-
else {
139-
//w.openFile(tmpfolder+"/"+zipname+"/"+zipname+".side");
140-
QMessageBox::critical(&w, w.tr("Cannot Open from Zip"),
141-
w.tr("The file is in a zipped archive. Unzip to")+"\n"+
142-
w.tr("a folder first, and open from there instead."));
143-
}
144-
}
59+
if(s.contains(QDir::toNativeSeparators(QDir::tempPath())) &&
60+
s.contains(".zip",Qt::CaseInsensitive)) {
61+
QMessageBox::critical(&w, w.tr("Cannot Open from Zip"),
62+
w.tr("The file is in a zipped archive. Unzip to")+"\n"+
63+
w.tr("a folder first, and open from there instead."));
14564
}
14665
else {
14766
s = s.mid(s.lastIndexOf("."));

0 commit comments

Comments
 (0)