author | llornkcor <llornkcor> | 2002-08-04 23:16:00 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-08-04 23:16:00 (UTC) |
commit | 400870188f123415355589ce4fb533614ecdf2ac (patch) (unidiff) | |
tree | 6dc7b0f747c3c48de6b730154c1167186226ec4a /noncore/apps | |
parent | 57bd412cf973805fbe69ecfa8f168ad2e28311a9 (diff) | |
download | opie-400870188f123415355589ce4fb533614ecdf2ac.zip opie-400870188f123415355589ce4fb533614ecdf2ac.tar.gz opie-400870188f123415355589ce4fb533614ecdf2ac.tar.bz2 |
fix several severe file handling bugs
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 120 |
1 files changed, 67 insertions, 53 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 818a281..b169a79 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1005,2 +1005,3 @@ QStringList AdvancedFm::getPath() { | |||
1005 | strList << it.current()->text(0); | 1005 | strList << it.current()->text(0); |
1006 | qDebug(it.current()->text(0)); | ||
1006 | } | 1007 | } |
@@ -1014,2 +1015,3 @@ QStringList AdvancedFm::getPath() { | |||
1014 | strList << it.current()->text(0); | 1015 | strList << it.current()->text(0); |
1016 | qDebug(it.current()->text(0)); | ||
1015 | } | 1017 | } |
@@ -1101,2 +1103,3 @@ void AdvancedFm::copy() | |||
1101 | { | 1103 | { |
1104 | qApp->processEvents(); | ||
1102 | QStringList curFileList = getPath(); | 1105 | QStringList curFileList = getPath(); |
@@ -1108,3 +1111,7 @@ void AdvancedFm::copy() | |||
1108 | QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1111 | QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1112 | qDebug("Destination file is "+destFile); | ||
1113 | |||
1109 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1114 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1115 | qDebug("CurrentFile file is " + curFile); | ||
1116 | |||
1110 | QFile f(destFile); | 1117 | QFile f(destFile); |
@@ -1134,3 +1141,5 @@ void AdvancedFm::copy() | |||
1134 | QString destFile = currentDir.canonicalPath()+"/"+(*it); | 1141 | QString destFile = currentDir.canonicalPath()+"/"+(*it); |
1142 | qDebug("Destination file is "+destFile); | ||
1135 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1143 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1144 | qDebug("CurrentFile file is " + curFile); | ||
1136 | 1145 | ||
@@ -1158,2 +1167,3 @@ void AdvancedFm::copy() | |||
1158 | } | 1167 | } |
1168 | |||
1159 | } | 1169 | } |
@@ -1161,11 +1171,10 @@ void AdvancedFm::copy() | |||
1161 | 1171 | ||
1162 | void AdvancedFm::copyAs() | 1172 | void AdvancedFm::copyAs() { |
1163 | { | 1173 | qApp->processEvents(); |
1174 | |||
1164 | QStringList curFileList = getPath(); | 1175 | QStringList curFileList = getPath(); |
1165 | if( curFileList.count() > 0) { | ||
1166 | QString curFile; | 1176 | QString curFile; |
1167 | InputDialog *fileDlg; | 1177 | InputDialog *fileDlg; |
1168 | fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); | ||
1169 | |||
1170 | if (TabWidget->currentPageIndex() == 0) { | 1178 | if (TabWidget->currentPageIndex() == 0) { |
1179 | qDebug("tab 1"); | ||
1171 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1180 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
@@ -1173,7 +1182,10 @@ void AdvancedFm::copyAs() | |||
1173 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1182 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1183 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | ||
1184 | |||
1174 | fileDlg->setInputText((const QString &) destFile ); | 1185 | fileDlg->setInputText((const QString &) destFile ); |
1175 | fileDlg->exec(); | 1186 | fileDlg->exec(); |
1187 | |||
1176 | if( fileDlg->result() == 1 ) { | 1188 | if( fileDlg->result() == 1 ) { |
1177 | QString filename = fileDlg->LineEdit1->text(); | 1189 | QString filename = fileDlg->LineEdit1->text(); |
1178 | destFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1190 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; |
1179 | 1191 | ||
@@ -1197,2 +1209,4 @@ void AdvancedFm::copyAs() | |||
1197 | } | 1209 | } |
1210 | delete fileDlg; | ||
1211 | |||
1198 | } | 1212 | } |
@@ -1200,7 +1214,9 @@ void AdvancedFm::copyAs() | |||
1200 | TabWidget->setCurrentPage(1); | 1214 | TabWidget->setCurrentPage(1); |
1215 | |||
1201 | } else { | 1216 | } else { |
1202 | if (TabWidget->currentPageIndex() == 0) { | ||
1203 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1217 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1204 | 1218 | ||
1205 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1219 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1220 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | ||
1221 | |||
1206 | QString destFile; | 1222 | QString destFile; |
@@ -1208,5 +1224,6 @@ void AdvancedFm::copyAs() | |||
1208 | fileDlg->exec(); | 1224 | fileDlg->exec(); |
1225 | |||
1209 | if( fileDlg->result() == 1 ) { | 1226 | if( fileDlg->result() == 1 ) { |
1210 | QString filename = fileDlg->LineEdit1->text(); | 1227 | QString filename = fileDlg->LineEdit1->text(); |
1211 | destFile = currentDir.canonicalPath()+"/"+(*it); | 1228 | destFile = currentDir.canonicalPath()+"/"+filename; |
1212 | 1229 | ||
@@ -1231,2 +1248,4 @@ void AdvancedFm::copyAs() | |||
1231 | } | 1248 | } |
1249 | delete fileDlg; | ||
1250 | |||
1232 | } | 1251 | } |
@@ -1236,9 +1255,6 @@ void AdvancedFm::copyAs() | |||
1236 | } | 1255 | } |
1237 | } | ||
1238 | |||
1239 | } | ||
1240 | 1256 | ||
1241 | void AdvancedFm::copySameDir() { | 1257 | void AdvancedFm::copySameDir() { |
1258 | qApp->processEvents(); | ||
1242 | QStringList curFileList = getPath(); | 1259 | QStringList curFileList = getPath(); |
1243 | if( curFileList.count() > 0) { | ||
1244 | QString curFile; | 1260 | QString curFile; |
@@ -1247,5 +1263,8 @@ void AdvancedFm::copySameDir() { | |||
1247 | if (TabWidget->currentPageIndex() == 0) { | 1263 | if (TabWidget->currentPageIndex() == 0) { |
1264 | |||
1248 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1265 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1266 | |||
1249 | QString destFile; | 1267 | QString destFile; |
1250 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1268 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1269 | |||
1251 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 1270 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
@@ -1253,3 +1272,5 @@ void AdvancedFm::copySameDir() { | |||
1253 | fileDlg->exec(); | 1272 | fileDlg->exec(); |
1273 | |||
1254 | if( fileDlg->result() == 1 ) { | 1274 | if( fileDlg->result() == 1 ) { |
1275 | |||
1255 | QString filename = fileDlg->LineEdit1->text(); | 1276 | QString filename = fileDlg->LineEdit1->text(); |
@@ -1280,6 +1301,5 @@ void AdvancedFm::copySameDir() { | |||
1280 | } | 1301 | } |
1281 | populateRemoteView(); | 1302 | populateLocalView(); |
1282 | TabWidget->setCurrentPage(1); | 1303 | |
1283 | } else { | 1304 | } else { |
1284 | if (TabWidget->currentPageIndex() == 0) { | ||
1285 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1305 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
@@ -1287,2 +1307,3 @@ void AdvancedFm::copySameDir() { | |||
1287 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1307 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1308 | |||
1288 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 1309 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
@@ -1293,3 +1314,4 @@ void AdvancedFm::copySameDir() { | |||
1293 | QString filename = fileDlg->LineEdit1->text(); | 1314 | QString filename = fileDlg->LineEdit1->text(); |
1294 | destFile = currentDir.canonicalPath()+"/"+filename; | 1315 | |
1316 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | ||
1295 | 1317 | ||
@@ -1316,8 +1338,4 @@ void AdvancedFm::copySameDir() { | |||
1316 | } | 1338 | } |
1317 | populateLocalView(); | 1339 | populateRemoteView(); |
1318 | TabWidget->setCurrentPage(0); | ||
1319 | } | ||
1320 | } | ||
1321 | } | 1340 | } |
1322 | |||
1323 | } | 1341 | } |
@@ -1325,2 +1343,3 @@ void AdvancedFm::copySameDir() { | |||
1325 | void AdvancedFm::move() { | 1343 | void AdvancedFm::move() { |
1344 | qApp->processEvents(); | ||
1326 | 1345 | ||
@@ -1329,3 +1348,2 @@ void AdvancedFm::move() { | |||
1329 | QString curFile; | 1348 | QString curFile; |
1330 | // qDebug(curFile); | ||
1331 | QString destFile; | 1349 | QString destFile; |
@@ -1333,4 +1351,7 @@ void AdvancedFm::move() { | |||
1333 | if (TabWidget->currentPageIndex() == 0) { | 1351 | if (TabWidget->currentPageIndex() == 0) { |
1352 | |||
1334 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1353 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1354 | |||
1335 | QString destFile = currentRemoteDir.canonicalPath(); | 1355 | QString destFile = currentRemoteDir.canonicalPath(); |
1356 | |||
1336 | if(destFile.right(1).find("/",0,TRUE) == -1) | 1357 | if(destFile.right(1).find("/",0,TRUE) == -1) |
@@ -1339,19 +1360,13 @@ void AdvancedFm::move() { | |||
1339 | curFile = currentDir.canonicalPath(); | 1360 | curFile = currentDir.canonicalPath(); |
1361 | |||
1340 | qDebug("Destination file is "+destFile); | 1362 | qDebug("Destination file is "+destFile); |
1363 | |||
1341 | if(curFile.right(1).find("/",0,TRUE) == -1) | 1364 | if(curFile.right(1).find("/",0,TRUE) == -1) |
1342 | curFile +="/"; | 1365 | curFile +="/"; |
1366 | |||
1343 | curFile+=(*it); | 1367 | curFile+=(*it); |
1368 | qDebug("CurrentFile file is " + curFile); | ||
1344 | 1369 | ||
1345 | QFile f(destFile); | 1370 | QFile f( curFile); |
1346 | if( f.exists()) { | 1371 | if( f.exists()) { |
1347 | switch (QMessageBox::warning(this,tr("Delete"), | ||
1348 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
1349 | tr("Yes"),tr("No"),0,0,1) ) { | ||
1350 | case 0: | ||
1351 | f.remove(); | ||
1352 | break; | ||
1353 | case 1: | ||
1354 | return; | ||
1355 | break; | ||
1356 | }; | ||
1357 | if(!copyFile( destFile, curFile) ) { | 1372 | if(!copyFile( destFile, curFile) ) { |
@@ -1359,3 +1374,3 @@ void AdvancedFm::move() { | |||
1359 | return; | 1374 | return; |
1360 | } | 1375 | } else |
1361 | QFile::remove(curFile); | 1376 | QFile::remove(curFile); |
@@ -1363,11 +1378,20 @@ void AdvancedFm::move() { | |||
1363 | } | 1378 | } |
1379 | |||
1364 | TabWidget->setCurrentPage(1); | 1380 | TabWidget->setCurrentPage(1); |
1365 | } else { | 1381 | |
1382 | } else { //view 2 | ||
1383 | |||
1366 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1384 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1367 | QString destFile = currentRemoteDir.canonicalPath(); | 1385 | |
1386 | QString destFile = currentDir.canonicalPath(); | ||
1387 | |||
1368 | if(destFile.right(1).find("/",0,TRUE) == -1) | 1388 | if(destFile.right(1).find("/",0,TRUE) == -1) |
1369 | destFile+="/"; | 1389 | destFile+="/"; |
1390 | |||
1370 | destFile +=(*it); | 1391 | destFile +=(*it); |
1392 | |||
1371 | qDebug("Destination file is "+destFile); | 1393 | qDebug("Destination file is "+destFile); |
1372 | curFile = currentDir.canonicalPath(); | 1394 | |
1395 | curFile = currentRemoteDir.canonicalPath(); | ||
1396 | |||
1373 | if(curFile.right(1).find("/",0,TRUE) == -1) | 1397 | if(curFile.right(1).find("/",0,TRUE) == -1) |
@@ -1375,15 +1399,6 @@ void AdvancedFm::move() { | |||
1375 | curFile+=(*it); | 1399 | curFile+=(*it); |
1400 | qDebug("CurrentFile file is " + curFile); | ||
1376 | 1401 | ||
1377 | QFile f(destFile); | 1402 | QFile f( curFile); |
1378 | if( f.exists()) { | 1403 | if( f.exists()) { |
1379 | switch (QMessageBox::warning(this,tr("Delete"), | ||
1380 | destFile+tr(" already exists\nDo you really want to delete it?"), | ||
1381 | tr("Yes"),tr("No"),0,0,1) ) { | ||
1382 | case 0: | ||
1383 | f.remove(); | ||
1384 | break; | ||
1385 | case 1: | ||
1386 | return; | ||
1387 | break; | ||
1388 | }; | ||
1389 | if(!copyFile(destFile, curFile) ) { | 1404 | if(!copyFile(destFile, curFile) ) { |
@@ -1391,5 +1406,5 @@ void AdvancedFm::move() { | |||
1391 | return; | 1406 | return; |
1392 | } | 1407 | } else |
1393 | } | ||
1394 | QFile::remove(curFile); | 1408 | QFile::remove(curFile); |
1409 | } | ||
1395 | TabWidget->setCurrentPage(0); | 1410 | TabWidget->setCurrentPage(0); |
@@ -1402,4 +1417,3 @@ void AdvancedFm::move() { | |||
1402 | 1417 | ||
1403 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) | 1418 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) { |
1404 | { | ||
1405 | char bf[ 50000 ]; | 1419 | char bf[ 50000 ]; |