1 /* Copyright (c) 2000, Len Budney. See COPYING for details. */ 2 3 #include "stat_dir.h" 4 #include "strerr.h" 5 #include <sys/stat.h> 6 #include <unistd.h> 7 8 /* ****************************************************************** */ stat_dir(char * dirname)9void stat_dir(char *dirname) { 10 struct stat filestat; 11 12 if(stat(dirname,&filestat) != 0) { 13 strerr_die2sys(111,"safecat: fatal: ","could not stat directory: "); 14 } 15 if( !S_ISDIR(filestat.st_mode) ) { 16 strerr_die2x(111, "safecat: fatal: ","not a directory"); 17 } 18 if((filestat.st_mode & S_IWUSR) != S_IWUSR) { 19 strerr_die2x(111, "safecat: fatal: ","directory not writable"); 20 } 21 filestat.st_mode = 0; 22 } 23 /* ****************************************************************** */ 24