Process recursive folder for spiffs images (#320)
* Process rercursive folder for spiffs images * Flat file name from the directory structure * change method to find '/' as the suggestion of @sheinz * remove unused variable
This commit is contained in:
parent
2b915c11c7
commit
ebfbc1144c
1 changed files with 13 additions and 3 deletions
|
@ -178,7 +178,7 @@ static bool process_directory(const char *direcotry)
|
||||||
{
|
{
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
struct dirent *ep;
|
struct dirent *ep;
|
||||||
char path[256];
|
char path[256], *filename;
|
||||||
|
|
||||||
dp = opendir(direcotry);
|
dp = opendir(direcotry);
|
||||||
if (dp != NULL) {
|
if (dp != NULL) {
|
||||||
|
@ -187,12 +187,22 @@ static bool process_directory(const char *direcotry)
|
||||||
!strcmp(ep->d_name, "..")) {
|
!strcmp(ep->d_name, "..")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if(ep->d_type == DT_DIR) {
|
||||||
|
char *new_dir_name = malloc(strlen(direcotry) + strlen(ep->d_name) + 2);
|
||||||
|
sprintf(new_dir_name, "%s/%s", direcotry, ep->d_name);
|
||||||
|
process_directory(new_dir_name);
|
||||||
|
free(new_dir_name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (ep->d_type != DT_REG) {
|
if (ep->d_type != DT_REG) {
|
||||||
continue; // not a regular file
|
continue; // not a regular file
|
||||||
}
|
}
|
||||||
sprintf(path, "%s/%s", direcotry, ep->d_name);
|
sprintf(path, "%s/%s", direcotry, ep->d_name);
|
||||||
printf("Processing file %s\n", path);
|
filename = strchr(path, '/');
|
||||||
if (!process_file(path, ep->d_name)) {
|
filename = filename ? &filename[1] : path;
|
||||||
|
|
||||||
|
printf("Processing file source %s, dest: %s\n", path, filename);
|
||||||
|
if (!process_file(path, filename)) {
|
||||||
printf("Error processing file\n");
|
printf("Error processing file\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue