mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-24 13:06:49 +03:00
Check return value of stat() in filename.c and report oddness using LOG
svn path=/trunk/netsurf/; revision=3318
This commit is contained in:
parent
818a744178
commit
47f9ee3581
@ -16,6 +16,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -225,7 +226,10 @@ bool filename_flush_directory(const char *folder, int depth) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
snprintf(child, 256, "%s/%s", folder, entry->d_name);
|
snprintf(child, 256, "%s/%s", folder, entry->d_name);
|
||||||
stat(child, &statbuf);
|
if (stat(child, &statbuf) == -1) {
|
||||||
|
LOG(("Unable to stat %s, even though it just got returned from readdir(): %s", child, strerror(errno)));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* first 3 depths are directories only, then files only */
|
/* first 3 depths are directories only, then files only */
|
||||||
if (depth < 3)
|
if (depth < 3)
|
||||||
@ -309,7 +313,11 @@ bool filename_delete_recursive(char *folder) {
|
|||||||
(!strcmp(entry->d_name, "..")))
|
(!strcmp(entry->d_name, "..")))
|
||||||
continue;
|
continue;
|
||||||
snprintf(child, 256, "%s/%s", folder, entry->d_name);
|
snprintf(child, 256, "%s/%s", folder, entry->d_name);
|
||||||
stat(child, &statbuf);
|
if (stat(child, &statbuf) == -1) {
|
||||||
|
LOG(("Unable to stat %s, even though it just got returned from readdir(): %s", child, strerror(errno)));
|
||||||
|
continue;
|
||||||
|
|
||||||
|
}
|
||||||
if (S_ISDIR(statbuf.st_mode)) {
|
if (S_ISDIR(statbuf.st_mode)) {
|
||||||
if (!filename_delete_recursive(child)) {
|
if (!filename_delete_recursive(child)) {
|
||||||
closedir(parent);
|
closedir(parent);
|
||||||
|
Loading…
Reference in New Issue
Block a user