This commit is contained in:
Pierre Pronchery 2004-07-21 16:03:49 +00:00
parent f424be094f
commit f00928ec13

View File

@ -45,6 +45,7 @@ static int _test(int argc, char * argv[])
/* n */ static int _is_string_not_empty(char * string);
/* r */ static int _is_file_readable(char * pathname);
/* S */ static int _is_file_socket(char * pathname);
/* s */ static int _is_file_size(char * pathname);
/* w */ static int _is_file_writable(char * pathname);
/* x */ static int _is_file_executable(char * pathname);
/* z */ static int _is_string_empty(char * string);
@ -73,6 +74,8 @@ static int _test_single(char c, char * argv)
return _is_file_readable(argv);
case 'S':
return _is_file_socket(argv);
case 's':
return _is_file_size(argv);
case 'w':
return _is_file_writable(argv);
case 'x':
@ -199,6 +202,15 @@ static int _is_file_socket(char * pathname)
return (st.st_mode & S_IFSOCK) ? 1 : 0; /* FIXME */
}
static int _is_file_size(char * pathname)
{
struct stat st;
if(stat(pathname, &st) != 0)
return 0;
return st.st_size > 0 ? 1 : 0;
}
static int _is_string_empty(char * string)
{
return *string == '\0' ? 1 : 0;