Skip to content

Commit e719af5

Browse files
committed
Remove VSIReadDirRecursive1()
This function was introduced at a time where some GDAL versions didn't have VSIReadDirRecursive(). Since we now require GDAL 2.1, this is safe to use plain VSIReadDirRecursive1()
1 parent 79ba0ee commit e719af5

File tree

1 file changed

+2
-67
lines changed

1 file changed

+2
-67
lines changed

src/core/qgsdataitem.cpp

+2-67
Original file line numberDiff line numberDiff line change
@@ -1342,71 +1342,6 @@ void QgsZipItem::init()
13421342

13431343
}
13441344

1345-
// internal function to scan a vsidir (zip or tar file) recursively
1346-
// GDAL trunk has this since r24423 (05/16/12) - VSIReadDirRecursive()
1347-
// use a copy of the function internally for now,
1348-
// but use char ** and CSLAddString, because CPLStringList was added in gdal-1.9
1349-
char **VSIReadDirRecursive1( const char *pszPath )
1350-
{
1351-
// CPLStringList oFiles = nullptr;
1352-
char **papszOFiles = nullptr;
1353-
char **papszFiles1 = nullptr;
1354-
char **papszFiles2 = nullptr;
1355-
VSIStatBufL psStatBuf;
1356-
QString temp1, temp2;
1357-
int i, j;
1358-
int nCount1, nCount2;
1359-
1360-
// get listing
1361-
papszFiles1 = VSIReadDir( pszPath );
1362-
if ( ! papszFiles1 )
1363-
return nullptr;
1364-
1365-
// get files and directories inside listing
1366-
nCount1 = CSLCount( papszFiles1 );
1367-
for ( i = 0; i < nCount1; i++ )
1368-
{
1369-
// build complete file name for stat
1370-
temp1 = QString( "%1/%2" ).arg( pszPath, papszFiles1[i] );
1371-
1372-
// if is file, add it
1373-
if ( VSIStatL( temp1.toUtf8(), &psStatBuf ) == 0 &&
1374-
VSI_ISREG( psStatBuf.st_mode ) )
1375-
{
1376-
// oFiles.AddString( papszFiles1[i] );
1377-
papszOFiles = CSLAddString( papszOFiles, papszFiles1[i] );
1378-
}
1379-
else if ( VSIStatL( temp1.toUtf8(), &psStatBuf ) == 0 &&
1380-
VSI_ISDIR( psStatBuf.st_mode ) )
1381-
{
1382-
// add directory entry
1383-
temp2 = QString( "%1/" ).arg( papszFiles1[i] );
1384-
1385-
// oFiles.AddString( temp2.toUtf8() );
1386-
papszOFiles = CSLAddString( papszOFiles, temp2.toUtf8() );
1387-
1388-
// recursively add files inside directory
1389-
papszFiles2 = VSIReadDirRecursive1( temp1.toUtf8() );
1390-
if ( papszFiles2 )
1391-
{
1392-
nCount2 = CSLCount( papszFiles2 );
1393-
for ( j = 0; j < nCount2; j++ )
1394-
{
1395-
temp2 = QString( "%1/%2" ).arg( papszFiles1[i], papszFiles2[j] );
1396-
1397-
// oFiles.AddString( temp2.toUtf8() );
1398-
papszOFiles = CSLAddString( papszOFiles, temp2.toUtf8() );
1399-
}
1400-
CSLDestroy( papszFiles2 );
1401-
}
1402-
}
1403-
}
1404-
CSLDestroy( papszFiles1 );
1405-
1406-
// return oFiles.StealList();
1407-
return papszOFiles;
1408-
}
1409-
14101345
QVector<QgsDataItem *> QgsZipItem::createChildren()
14111346
{
14121347
QVector<QgsDataItem *> children;
@@ -1599,10 +1534,10 @@ QStringList QgsZipItem::getZipFileList()
15991534

16001535
// get list of files inside zip file
16011536
QgsDebugMsgLevel( QString( "Open file %1 with gdal vsi" ).arg( mVsiPrefix + mFilePath ), 3 );
1602-
char **papszSiblingFiles = VSIReadDirRecursive1( QString( mVsiPrefix + mFilePath ).toLocal8Bit().constData() );
1537+
char **papszSiblingFiles = VSIReadDirRecursive( QString( mVsiPrefix + mFilePath ).toLocal8Bit().constData() );
16031538
if ( papszSiblingFiles )
16041539
{
1605-
for ( int i = 0; i < CSLCount( papszSiblingFiles ); i++ )
1540+
for ( int i = 0; papszSiblingFiles[i]; i++ )
16061541
{
16071542
tmpPath = papszSiblingFiles[i];
16081543
QgsDebugMsgLevel( QString( "Read file %1" ).arg( tmpPath ), 3 );

0 commit comments

Comments
 (0)