@@ -774,59 +774,68 @@ QgsZipItem::~QgsZipItem()
774
774
}
775
775
776
776
// internal function to scan a vsidir (zip or tar file) recursively
777
- // hopefully this will make it to GDAL
777
+ // GDAL trunk has this since r24423 (05/16/12) - VSIReadDirRecursive()
778
+ // use a copy of the function internally for now
778
779
char **VSIReadDirRecursive1 ( const char *pszPath )
779
780
{
780
- char **papszFiles = NULL ;
781
+ CPLStringList oFiles = NULL ;
781
782
char **papszFiles1 = NULL ;
782
783
char **papszFiles2 = NULL ;
783
784
VSIStatBufL psStatBuf;
784
- char szTemp1[1096 ];
785
- char szTemp2[1096 ];
785
+ CPLString osTemp1, osTemp2;
786
+ int i, j;
787
+ int nCount1, nCount2;
786
788
787
789
// get listing
788
790
papszFiles1 = VSIReadDir ( pszPath );
789
791
if ( ! papszFiles1 )
790
792
return NULL ;
791
793
792
794
// get files and directories inside listing
793
- for ( int i = 0 ; i < CSLCount ( papszFiles1 ); i++ )
795
+ nCount1 = CSLCount ( papszFiles1 );
796
+ for ( i = 0 ; i < nCount1; i++ )
794
797
{
795
798
// build complete file name for stat
796
- strcpy ( szTemp1, pszPath );
797
- strcat ( szTemp1, ( char * )" /" ); // this might not be ok on windows
798
- strcat ( szTemp1, papszFiles1[i] );
799
+ osTemp1.clear ();
800
+ osTemp1.append ( pszPath );
801
+ osTemp1.append ( " /" );
802
+ osTemp1.append ( papszFiles1[i] );
803
+
799
804
// if is file, add it
800
- if ( VSIStatL ( szTemp1 , &psStatBuf ) == 0 &&
805
+ if ( VSIStatL ( osTemp1. c_str () , &psStatBuf ) == 0 &&
801
806
VSI_ISREG ( psStatBuf.st_mode ) )
802
807
{
803
- papszFiles = CSLAddString ( papszFiles, papszFiles1[i] );
808
+ oFiles. AddString ( papszFiles1[i] );
804
809
}
805
- else if ( VSIStatL ( szTemp1 , &psStatBuf ) == 0 &&
810
+ else if ( VSIStatL ( osTemp1. c_str () , &psStatBuf ) == 0 &&
806
811
VSI_ISDIR ( psStatBuf.st_mode ) )
807
812
{
808
813
// add directory entry
809
- strcpy ( szTemp2, papszFiles1[i] );
810
- strcat ( szTemp2, ( char * )" /" ); // this might not be ok on windows
811
- papszFiles = CSLAddString ( papszFiles, szTemp2 );
814
+ osTemp2.clear ();
815
+ osTemp2.append ( papszFiles1[i] );
816
+ osTemp2.append ( " /" );
817
+ oFiles.AddString ( osTemp2.c_str () );
818
+
812
819
// recursively add files inside directory
813
- papszFiles2 = VSIReadDirRecursive1 ( szTemp1 );
820
+ papszFiles2 = VSIReadDirRecursive1 ( osTemp1. c_str () );
814
821
if ( papszFiles2 )
815
822
{
816
- for ( int j = 0 ; j < CSLCount ( papszFiles2 ); j++ )
823
+ nCount2 = CSLCount ( papszFiles2 );
824
+ for ( j = 0 ; j < nCount2; j++ )
817
825
{
818
- strcpy ( szTemp2, papszFiles1[i] );
819
- strcat ( szTemp2, ( char * )" /" ); // this might not be ok on windows
820
- strcat ( szTemp2, papszFiles2[j] );
821
- papszFiles = CSLAddString ( papszFiles, szTemp2 );
826
+ osTemp2.clear ();
827
+ osTemp2.append ( papszFiles1[i] );
828
+ osTemp2.append ( " /" );
829
+ osTemp2.append ( papszFiles2[j] );
830
+ oFiles.AddString ( osTemp2.c_str () );
822
831
}
823
832
CSLDestroy ( papszFiles2 );
824
833
}
825
834
}
826
835
}
827
836
CSLDestroy ( papszFiles1 );
828
837
829
- return papszFiles ;
838
+ return oFiles. StealList () ;
830
839
}
831
840
832
841
QVector<QgsDataItem*> QgsZipItem::createChildren ( )
0 commit comments