diff options
author | Anton L. Šijanec <sijanecantonluka@gmail.com> | 2020-05-14 19:19:34 +0200 |
---|---|---|
committer | Anton L. Šijanec <sijanecantonluka@gmail.com> | 2020-05-14 19:19:34 +0200 |
commit | 3fa7dde6977f60e78c1e9d7a84ca8f8b1a58ab96 (patch) | |
tree | dbc60645631e1ccae8546b6929388cf7af281022 /src/jsbundle.c | |
parent | // => /**/ for CSS (diff) | |
download | bverbose-3fa7dde6977f60e78c1e9d7a84ca8f8b1a58ab96.tar bverbose-3fa7dde6977f60e78c1e9d7a84ca8f8b1a58ab96.tar.gz bverbose-3fa7dde6977f60e78c1e9d7a84ca8f8b1a58ab96.tar.bz2 bverbose-3fa7dde6977f60e78c1e9d7a84ca8f8b1a58ab96.tar.lz bverbose-3fa7dde6977f60e78c1e9d7a84ca8f8b1a58ab96.tar.xz bverbose-3fa7dde6977f60e78c1e9d7a84ca8f8b1a58ab96.tar.zst bverbose-3fa7dde6977f60e78c1e9d7a84ca8f8b1a58ab96.zip |
Diffstat (limited to 'src/jsbundle.c')
-rw-r--r-- | src/jsbundle.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/jsbundle.c b/src/jsbundle.c index f7bf8d2..082794a 100644 --- a/src/jsbundle.c +++ b/src/jsbundle.c @@ -25,17 +25,20 @@ int bundle_js(char* bundle_filename, char* js_source_folder_name, char* file_ext mkdir_p(bundle_filename); } char copy_buffer; - DIR *dir; - struct dirent *ent; + // DIR *dir; + struct dirent **ent; + int number_of_files; // printf ("[jsbundle.c] bundle_filename: %s\n", bundle_filename); - if ((dir = opendir (js_source_folder_name)) != NULL) { + number_of_files = scandir(js_source_folder_name, &ent, NULL, alphasort); + if (number_of_files > -1) { /* print all the files and directories within directory */ - while ((ent = readdir (dir)) != NULL) { - if(strcmp(ent->d_name, ".") != 0 && strcmp(ent->d_name, "..") != 0) { - char *dot = strrchr(ent->d_name, '.'); + for (int i = 0; i < number_of_files; i++) { + if(strcmp(ent[i]->d_name, ".") != 0 && strcmp(ent[i]->d_name, "..") != 0) { + char *dot = strrchr(ent[i]->d_name, '.'); if(dot && !strcmp(dot, file_extension)) { + fprintf(stderr, "[jsbundle.c] bundling file %s\n", ent[i]->d_name); strcpy(source_filename, js_source_folder_name); - strcat(source_filename, ent->d_name); + strcat(source_filename, ent[i]->d_name); source_file = fopen(source_filename, "r"); // printf("[jsbundle.c] source_filename: %s\n", source_filename); fprintf(bundle_file, "\n/* %s */\n", source_filename); @@ -48,7 +51,7 @@ int bundle_js(char* bundle_filename, char* js_source_folder_name, char* file_ext } } } - closedir (dir); + // closedir (dir); fclose(bundle_file); } else { /* could not open directory */ |