Get rid of plib to enumerate files. Get a list of files when the directory names contains UTF-8 characters. Doesn't fix issues #394 though because untarka functions should be utf-8 aware
This commit is contained in:
parent
02cf9774e8
commit
3a17ef2f1a
2 changed files with 32 additions and 25 deletions
|
@ -65,7 +65,7 @@
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="fltkd.lib ul_d.lib comctl32.lib wsock32.lib zlibd.lib sg_d.lib"
|
AdditionalDependencies="fltkd.lib comctl32.lib wsock32.lib zlibd.lib"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
AdditionalLibraryDirectories="..\..\..\..\3rdParty\lib"
|
AdditionalLibraryDirectories="..\..\..\..\3rdParty\lib"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
|
@ -145,7 +145,7 @@
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="fltkd.lib ul_d.lib comctl32.lib wsock32.lib zlibd.lib sg_d.lib"
|
AdditionalDependencies="fltkd.lib comctl32.lib wsock32.lib zlibd.lib"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
AdditionalLibraryDirectories="..\..\..\..\3rdParty.x64\lib"
|
AdditionalLibraryDirectories="..\..\..\..\3rdParty.x64\lib"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
|
@ -226,7 +226,7 @@
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="fltk.lib ul.lib sg.lib comctl32.lib wsock32.lib zlib.lib"
|
AdditionalDependencies="fltk.lib comctl32.lib wsock32.lib zlib.lib"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
AdditionalLibraryDirectories="..\..\..\..\3rdParty\lib"
|
AdditionalLibraryDirectories="..\..\..\..\3rdParty\lib"
|
||||||
GenerateDebugInformation="false"
|
GenerateDebugInformation="false"
|
||||||
|
@ -309,7 +309,7 @@
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="fltk.lib ul.lib sg.lib comctl32.lib wsock32.lib zlib.lib"
|
AdditionalDependencies="fltk.lib sg.lib comctl32.lib wsock32.lib"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
AdditionalLibraryDirectories="..\..\..\..\3rdParty.x64\lib"
|
AdditionalLibraryDirectories="..\..\..\..\3rdParty.x64\lib"
|
||||||
GenerateDebugInformation="false"
|
GenerateDebugInformation="false"
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <FL/Fl_File_Chooser.H>
|
#include <FL/Fl_File_Chooser.H>
|
||||||
#include <plib/ul.h>
|
|
||||||
|
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
|
|
||||||
|
@ -142,11 +141,12 @@ void FGAdminUI::update_install_box() {
|
||||||
install_box->clear();
|
install_box->clear();
|
||||||
|
|
||||||
if ( source.length() ) {
|
if ( source.length() ) {
|
||||||
ulDir *dir = ulOpenDir( source.c_str() ) ;
|
struct dirent **list;
|
||||||
ulDirEnt *ent;
|
int nb = fl_filename_list( source.c_str(), &list );
|
||||||
while ( dir != 0 && ( ent = ulReadDir( dir ) ) ) {
|
for ( int i = 0; i < nb; ++i ) {
|
||||||
// find base name of archive file
|
// find base name of archive file
|
||||||
char base[FL_PATH_MAX];
|
char base[FL_PATH_MAX];
|
||||||
|
dirent *ent = list[i];
|
||||||
strncpy( base, ent->d_name, FL_PATH_MAX );
|
strncpy( base, ent->d_name, FL_PATH_MAX );
|
||||||
const char *p = fl_filename_ext( base );
|
const char *p = fl_filename_ext( base );
|
||||||
int offset, expected_length = 0;
|
int offset, expected_length = 0;
|
||||||
|
@ -186,9 +186,10 @@ void FGAdminUI::update_install_box() {
|
||||||
// cout << install.str() << " exists." << endl;
|
// cout << install.str() << " exists." << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free( ent );
|
||||||
}
|
}
|
||||||
|
free( list );
|
||||||
|
|
||||||
ulCloseDir( dir );
|
|
||||||
for ( set<string>::iterator it = file_list.begin(); it != file_list.end(); ++it ) {
|
for ( set<string>::iterator it = file_list.begin(); it != file_list.end(); ++it ) {
|
||||||
install_box->add( it->c_str() );
|
install_box->add( it->c_str() );
|
||||||
}
|
}
|
||||||
|
@ -217,16 +218,18 @@ void FGAdminUI::update_remove_box() {
|
||||||
set<string> dir_list;
|
set<string> dir_list;
|
||||||
for ( int i = 0; i < 2; i++ ) {
|
for ( int i = 0; i < 2; i++ ) {
|
||||||
if ( !path[i].empty() ) {
|
if ( !path[i].empty() ) {
|
||||||
ulDir *dir = ulOpenDir( path[i].c_str() ) ;
|
dirent **list;
|
||||||
ulDirEnt *ent;
|
int nb = fl_filename_list( path[i].c_str(), &list );
|
||||||
while ( dir != 0 && ( ent = ulReadDir( dir ) ) ) {
|
for ( int i = 0; i < nb; ++i ) {
|
||||||
|
dirent *ent = list[i];
|
||||||
if ( strlen(ent->d_name) == 7 &&
|
if ( strlen(ent->d_name) == 7 &&
|
||||||
( ent->d_name[0] == 'e' || ent->d_name[0] == 'w' ) &&
|
( ent->d_name[0] == 'e' || ent->d_name[0] == 'w' ) &&
|
||||||
( ent->d_name[4] == 'n' || ent->d_name[4] == 's' ) ) {
|
( ent->d_name[4] == 'n' || ent->d_name[4] == 's' ) ) {
|
||||||
dir_list.insert( ent->d_name );
|
dir_list.insert( ent->d_name );
|
||||||
}
|
}
|
||||||
|
free( ent );
|
||||||
}
|
}
|
||||||
ulCloseDir( dir );
|
free( list );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,23 +282,25 @@ void FGAdminUI::install_selected() {
|
||||||
|
|
||||||
static unsigned long count_dir( const char *dir_name, bool top = true ) {
|
static unsigned long count_dir( const char *dir_name, bool top = true ) {
|
||||||
unsigned long cnt = 0L;
|
unsigned long cnt = 0L;
|
||||||
ulDir *dir = ulOpenDir( dir_name ) ;
|
dirent **list;
|
||||||
if ( dir ) {
|
int nb = fl_filename_list( dir_name, &list );
|
||||||
ulDirEnt *ent;
|
if ( nb != 0 ) {
|
||||||
while ( ent = ulReadDir( dir ) ) {
|
for ( int i = 0; i < nb; ++i ) {
|
||||||
|
dirent *ent = list[i];
|
||||||
if ( strcmp( ent->d_name, "." ) == 0 ) {
|
if ( strcmp( ent->d_name, "." ) == 0 ) {
|
||||||
// ignore "."
|
// ignore "."
|
||||||
} else if ( strcmp( ent->d_name, ".." ) == 0 ) {
|
} else if ( strcmp( ent->d_name, ".." ) == 0 ) {
|
||||||
// ignore ".."
|
// ignore ".."
|
||||||
} else if ( ent->d_isdir ) {
|
} else if ( fl_filename_isdir( ent->d_name ) ) {
|
||||||
SGPath child( dir_name );
|
SGPath child( dir_name );
|
||||||
child.append( ent->d_name );
|
child.append( ent->d_name );
|
||||||
cnt += count_dir( child.c_str(), false );
|
cnt += count_dir( child.c_str(), false );
|
||||||
} else {
|
} else {
|
||||||
cnt += 1;
|
cnt += 1;
|
||||||
}
|
}
|
||||||
|
free( ent );
|
||||||
}
|
}
|
||||||
ulCloseDir( dir );
|
free( list );
|
||||||
} else if ( top ) {
|
} else if ( top ) {
|
||||||
string base = dir_name;
|
string base = dir_name;
|
||||||
size_t pos = base.rfind('/');
|
size_t pos = base.rfind('/');
|
||||||
|
@ -310,15 +315,16 @@ static unsigned long count_dir( const char *dir_name, bool top = true ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void remove_dir( const char *dir_name, void (*step)(void*,int), void *data, bool top = true ) {
|
static void remove_dir( const char *dir_name, void (*step)(void*,int), void *data, bool top = true ) {
|
||||||
ulDir *dir = ulOpenDir( dir_name ) ;
|
dirent **list;
|
||||||
if ( dir ) {
|
int nb = fl_filename_list( dir_name, &list );
|
||||||
ulDirEnt *ent;
|
if ( nb != 0 ) {
|
||||||
while ( ent = ulReadDir( dir ) ) {
|
for ( int i = 0; i < nb; ++i ) {
|
||||||
|
dirent *ent = list[i];
|
||||||
if ( strcmp( ent->d_name, "." ) == 0 ) {
|
if ( strcmp( ent->d_name, "." ) == 0 ) {
|
||||||
// ignore "."
|
// ignore "."
|
||||||
} else if ( strcmp( ent->d_name, ".." ) == 0 ) {
|
} else if ( strcmp( ent->d_name, ".." ) == 0 ) {
|
||||||
// ignore ".."
|
// ignore ".."
|
||||||
} else if ( ent->d_isdir ) {
|
} else if ( fl_filename_isdir( ent->d_name ) ) {
|
||||||
SGPath child( dir_name );
|
SGPath child( dir_name );
|
||||||
child.append( ent->d_name );
|
child.append( ent->d_name );
|
||||||
remove_dir( child.c_str(), step, data, false );
|
remove_dir( child.c_str(), step, data, false );
|
||||||
|
@ -328,8 +334,9 @@ static void remove_dir( const char *dir_name, void (*step)(void*,int), void *dat
|
||||||
unlink( child.c_str() );
|
unlink( child.c_str() );
|
||||||
if (step) step( data, 1 );
|
if (step) step( data, 1 );
|
||||||
}
|
}
|
||||||
|
free( ent );
|
||||||
}
|
}
|
||||||
ulCloseDir( dir );
|
free( list );
|
||||||
rmdir( dir_name );
|
rmdir( dir_name );
|
||||||
} else if ( top ) {
|
} else if ( top ) {
|
||||||
string base = dir_name;
|
string base = dir_name;
|
||||||
|
|
Loading…
Add table
Reference in a new issue