@@ -200,7 +200,7 @@ bool QgsVectorFileWriter::addFeature(QgsFeature& feature)
200200 OGR_F_SetFieldString (poFeature, ogrField, mCodec ->fromUnicode (attrValue.toString ()).data ());
201201 break ;
202202 default :
203- // assert(0 && "invalid variant type" );
203+ QgsDebugMsg ( " Invalid variant type for field " + QString::number (ogrField)+ " : " + QString::number (attrValue. type ()) );
204204 return false ;
205205 }
206206 }
@@ -321,43 +321,25 @@ bool QgsVectorFileWriter::deleteShapeFile(QString theFileName)
321321{
322322 //
323323 // Remove old copies that may be lying around
324+ // TODO: should be case-insensitive
324325 //
325- QFileInfo myInfo (theFileName);
326326 QString myFileBase = theFileName.replace (" .shp" ," " );
327- if (myInfo.exists ())
328- {
329- if (!QFile::remove (myFileBase + " .shp" ))
330- {
331- qDebug (" Removing file failed : " + myFileBase.toLocal8Bit () + " .shp" );
332- return false ;
333- }
334- }
335- myInfo.setFile (myFileBase + " .shx" );
336- if (myInfo.exists ())
337- {
338- if (!QFile::remove (myFileBase + " .shx" ))
339- {
340- qDebug (" Removing file failed : " + myFileBase.toLocal8Bit () + " .shx" );
341- return false ;
342- }
343- }
344- myInfo.setFile (myFileBase + " .dbf" );
345- if (myInfo.exists ())
346- {
347- if (!QFile::remove (myFileBase + " .dbf" ))
348- {
349- qDebug (" Removing file failed : " + myFileBase.toLocal8Bit () + " .dbf" );
350- return false ;
351- }
352- }
353- myInfo.setFile (myFileBase + " .prj" );
354- if (myInfo.exists ())
327+ bool ok = TRUE ;
328+
329+ const char * suffixes[] = { " .shp" , " .shx" , " .dbf" , " .prj" , " .qix" };
330+ for (int i = 0 ; i < sizeof (suffixes) / sizeof (char *); i++)
355331 {
356- if (!QFile::remove (myFileBase + " .prj" ))
332+ QString file = myFileBase + suffixes[i];
333+ QFileInfo myInfo (file);
334+ if (myInfo.exists ())
357335 {
358- qDebug (" Removing file failed : " + myFileBase.toLocal8Bit () + " .prj" );
359- return false ;
336+ if (!QFile::remove (file))
337+ {
338+ QgsDebugMsg (" Removing file failed : " + file);
339+ ok = FALSE ;
340+ }
360341 }
361342 }
362- return true ;
343+
344+ return ok;
363345}
0 commit comments