|
|
|
@ -1111,118 +1111,8 @@ void format_speed_display (double val, char *buf, size_t len)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char **scan_directory (const char *path)
|
|
|
|
|
{
|
|
|
|
|
char *tmp_path = mystrdup (path);
|
|
|
|
|
|
|
|
|
|
size_t tmp_path_len = strlen (tmp_path);
|
|
|
|
|
|
|
|
|
|
while (tmp_path[tmp_path_len - 1] == '/' || tmp_path[tmp_path_len - 1] == '\\')
|
|
|
|
|
{
|
|
|
|
|
tmp_path[tmp_path_len - 1] = 0;
|
|
|
|
|
|
|
|
|
|
tmp_path_len = strlen (tmp_path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char **files = NULL;
|
|
|
|
|
|
|
|
|
|
int num_files = 0;
|
|
|
|
|
|
|
|
|
|
DIR *d = NULL;
|
|
|
|
|
|
|
|
|
|
if ((d = opendir (tmp_path)) != NULL)
|
|
|
|
|
{
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
|
|
|
|
|
|
struct dirent e;
|
|
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
memset (&e, 0, sizeof (e));
|
|
|
|
|
|
|
|
|
|
struct dirent *de = NULL;
|
|
|
|
|
|
|
|
|
|
if (readdir_r (d, &e, &de) != 0)
|
|
|
|
|
{
|
|
|
|
|
log_error ("ERROR: readdir_r() failed");
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (de == NULL) break;
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
struct dirent *de;
|
|
|
|
|
|
|
|
|
|
while ((de = readdir (d)) != NULL)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if ((strcmp (de->d_name, ".") == 0) || (strcmp (de->d_name, "..") == 0)) continue;
|
|
|
|
|
|
|
|
|
|
int path_size = strlen (tmp_path) + 1 + strlen (de->d_name);
|
|
|
|
|
|
|
|
|
|
char *path_file = (char *) mymalloc (path_size + 1);
|
|
|
|
|
|
|
|
|
|
snprintf (path_file, path_size + 1, "%s/%s", tmp_path, de->d_name);
|
|
|
|
|
|
|
|
|
|
path_file[path_size] = 0;
|
|
|
|
|
|
|
|
|
|
DIR *d_test;
|
|
|
|
|
|
|
|
|
|
if ((d_test = opendir (path_file)) != NULL)
|
|
|
|
|
{
|
|
|
|
|
closedir (d_test);
|
|
|
|
|
|
|
|
|
|
myfree (path_file);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
files = (char **) myrealloc (files, num_files * sizeof (char *), sizeof (char *));
|
|
|
|
|
|
|
|
|
|
num_files++;
|
|
|
|
|
|
|
|
|
|
files[num_files - 1] = path_file;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
closedir (d);
|
|
|
|
|
}
|
|
|
|
|
else if (errno == ENOTDIR)
|
|
|
|
|
{
|
|
|
|
|
files = (char **) myrealloc (files, num_files * sizeof (char *), sizeof (char *));
|
|
|
|
|
|
|
|
|
|
num_files++;
|
|
|
|
|
|
|
|
|
|
files[num_files - 1] = mystrdup (path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
files = (char **) myrealloc (files, num_files * sizeof (char *), sizeof (char *));
|
|
|
|
|
|
|
|
|
|
num_files++;
|
|
|
|
|
|
|
|
|
|
files[num_files - 1] = NULL;
|
|
|
|
|
|
|
|
|
|
myfree (tmp_path);
|
|
|
|
|
|
|
|
|
|
return (files);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int count_dictionaries (char **dictionary_files)
|
|
|
|
|
{
|
|
|
|
|
if (dictionary_files == NULL) return 0;
|
|
|
|
|
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
|
|
|
|
|
for (int d = 0; dictionary_files[d] != NULL; d++)
|
|
|
|
|
{
|
|
|
|
|
cnt++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (cnt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *stroptitype (const uint opti_type)
|
|
|
|
|
{
|
|
|
|
|