|
1 | 1 | #include <QtGui> |
2 | 2 | #include "mainspinwindow.h" |
3 | | -#include "quazip.h" |
4 | | -#include "quazipfile.h" |
5 | | -#include "directory.h" |
6 | 3 |
|
7 | 4 | int main(int argc, char *argv[]) |
8 | 5 | { |
@@ -59,89 +56,11 @@ int main(int argc, char *argv[]) |
59 | 56 |
|
60 | 57 | if(argc > 1) { |
61 | 58 | 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.")); |
145 | 64 | } |
146 | 65 | else { |
147 | 66 | s = s.mid(s.lastIndexOf(".")); |
|
0 commit comments