- if ((count = scandir(pi->phys, &files, uh_file_scandir_filter_dir,
- alphasort)) > 0)
- {
- int len;
-
- strcpy(filename, pi->phys);
- len = strlen(filename);
- pathptr = filename + len;
- len = PATH_MAX - len;
-
- /* list subdirs */
- for (i = 0; i < count; i++) {
- snprintf(pathptr, len, "%s", files[i]->d_name);
-
- if (!stat(filename, &s) &&
- (s.st_mode & S_IFDIR) && (s.st_mode & S_IXOTH))
- uh_chunk_printf(cl,
- "<li><strong><a href='%s%s/'>%s</a>/"
- "</strong><br /><small>modified: %s"
- "<br />directory - %.02f kbyte<br />"
- "<br /></small></li>",
- pi->name, files[i]->d_name,
- files[i]->d_name,
- uh_file_unix2date(s.st_mtime, buf, sizeof(buf)),
- s.st_size / 1024.0);
-
- *pathptr = 0;
- }
-
- /* list files */
- for (i = 0; i < count; i++) {
- snprintf(pathptr, len, "%s", files[i]->d_name);
-
- if (!stat(filename, &s) &&
- !(s.st_mode & S_IFDIR) && (s.st_mode & S_IROTH))
- uh_chunk_printf(cl,
- "<li><strong><a href='%s%s'>%s</a>"
- "</strong><br /><small>modified: %s"
- "<br />%s - %.02f kbyte<br />"
- "<br /></small></li>",
- pi->name, files[i]->d_name,
- files[i]->d_name,
- uh_file_unix2date(s.st_mtime, buf, sizeof(buf)),
- uh_file_mime_lookup(filename),
- s.st_size / 1024.0);
-
- *pathptr = 0;
- }
+ count = scandir(pi->phys, &files, NULL, dirent_cmp);
+ if (count > 0) {
+ strcpy(uh_buf, pi->phys);
+ list_entries(cl, files, count, pi->name, uh_buf);