Update For_each_directory_entry() for more args in callback
This commit is contained in:
parent
545308265b
commit
cb936b24e7
@ -2249,12 +2249,11 @@ void Draw_script_information(T_Fileselector_item * script_item, const char *full
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add a script to the list
|
// Add a script to the list
|
||||||
void Add_script(const char *name, byte is_file, byte is_directory, byte is_hidden)
|
static void Add_script(void * pdata, const char *file_name, const word *unicode_name, byte is_file, byte is_directory, byte is_hidden)
|
||||||
{
|
{
|
||||||
const char * file_name;
|
|
||||||
int len;
|
int len;
|
||||||
|
(void)pdata;
|
||||||
file_name=Find_last_separator(name)+1;
|
(void)unicode_name;
|
||||||
|
|
||||||
if (is_file)
|
if (is_file)
|
||||||
{
|
{
|
||||||
@ -2616,7 +2615,7 @@ void Reload_scripts_list(void)
|
|||||||
{
|
{
|
||||||
Add_element_to_list(&Scripts_selector, PARENT_DIR, Format_filename(PARENT_DIR, NAME_WIDTH+1, 1), 1, ICON_NONE);
|
Add_element_to_list(&Scripts_selector, PARENT_DIR, Format_filename(PARENT_DIR, NAME_WIDTH+1, 1), 1, ICON_NONE);
|
||||||
// Add each found file to the list
|
// Add each found file to the list
|
||||||
For_each_directory_entry(Config.Scripts_directory, Add_script);
|
For_each_directory_entry(Config.Scripts_directory, NULL, Add_script);
|
||||||
}
|
}
|
||||||
// Sort it
|
// Sort it
|
||||||
Sort_list_of_files(&Scripts_selector);
|
Sort_list_of_files(&Scripts_selector);
|
||||||
|
|||||||
8
src/io.c
8
src/io.c
@ -390,13 +390,15 @@ void For_each_file(const char * directory_name, void Callback(const char *))
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Scans a directory, calls Callback for each file or directory in it,
|
/// Scans a directory, calls Callback for each file or directory in it,
|
||||||
void For_each_directory_entry(const char * directory_name, void Callback(const char *, byte is_file, byte is_directory, byte is_hidden))
|
void For_each_directory_entry(const char * directory_name, void * pdata, T_File_dir_cb Callback)
|
||||||
{
|
{
|
||||||
// Pour scan de répertoire
|
// Pour scan de répertoire
|
||||||
DIR* current_directory; //Répertoire courant
|
DIR* current_directory; //Répertoire courant
|
||||||
struct dirent* entry; // Structure de lecture des éléments
|
struct dirent* entry; // Structure de lecture des éléments
|
||||||
char full_filename[MAX_PATH_CHARACTERS];
|
char full_filename[MAX_PATH_CHARACTERS];
|
||||||
|
word * unicode_filename = NULL;
|
||||||
int filename_position;
|
int filename_position;
|
||||||
|
|
||||||
strcpy(full_filename, directory_name);
|
strcpy(full_filename, directory_name);
|
||||||
current_directory=opendir(full_filename);
|
current_directory=opendir(full_filename);
|
||||||
if(current_directory == NULL) return; // Répertoire invalide ...
|
if(current_directory == NULL) return; // Répertoire invalide ...
|
||||||
@ -416,7 +418,9 @@ void For_each_directory_entry(const char * directory_name, void Callback(const c
|
|||||||
strcpy(&full_filename[filename_position], entry->d_name);
|
strcpy(&full_filename[filename_position], entry->d_name);
|
||||||
stat(full_filename,&Infos_enreg);
|
stat(full_filename,&Infos_enreg);
|
||||||
Callback(
|
Callback(
|
||||||
full_filename,
|
pdata,
|
||||||
|
entry->d_name,
|
||||||
|
unicode_filename,
|
||||||
S_ISREG(Infos_enreg.st_mode),
|
S_ISREG(Infos_enreg.st_mode),
|
||||||
S_ISDIR(Infos_enreg.st_mode),
|
S_ISDIR(Infos_enreg.st_mode),
|
||||||
File_is_hidden(entry->d_name, full_filename));
|
File_is_hidden(entry->d_name, full_filename));
|
||||||
|
|||||||
4
src/io.h
4
src/io.h
@ -96,8 +96,10 @@ int File_is_hidden(const char *fname, const char *full_name);
|
|||||||
/// Scans a directory, calls Callback for each file in it,
|
/// Scans a directory, calls Callback for each file in it,
|
||||||
void For_each_file(const char * directory_name, void Callback(const char *));
|
void For_each_file(const char * directory_name, void Callback(const char *));
|
||||||
|
|
||||||
|
typedef void T_File_dir_cb(void * pdata, const char * filename, const word * unicode_filename, byte is_file, byte is_directory, byte is_hidden);
|
||||||
|
|
||||||
/// Scans a directory, calls Callback for each file or directory in it,
|
/// Scans a directory, calls Callback for each file or directory in it,
|
||||||
void For_each_directory_entry(const char * directory_name, void Callback(const char *, byte is_file, byte is_directory, byte is_hidden));
|
void For_each_directory_entry(const char * directory_name, void * pdata, T_File_dir_cb Callback);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Creates a fully qualified name from a directory and filename.
|
/// Creates a fully qualified name from a directory and filename.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user