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); /* n */ static int _is_string_not_empty(char * string);
/* r */ static int _is_file_readable(char * pathname); /* r */ static int _is_file_readable(char * pathname);
/* S */ static int _is_file_socket(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); /* w */ static int _is_file_writable(char * pathname);
/* x */ static int _is_file_executable(char * pathname); /* x */ static int _is_file_executable(char * pathname);
/* z */ static int _is_string_empty(char * string); /* 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); return _is_file_readable(argv);
case 'S': case 'S':
return _is_file_socket(argv); return _is_file_socket(argv);
case 's':
return _is_file_size(argv);
case 'w': case 'w':
return _is_file_writable(argv); return _is_file_writable(argv);
case 'x': case 'x':
@ -199,6 +202,15 @@ static int _is_file_socket(char * pathname)
return (st.st_mode & S_IFSOCK) ? 1 : 0; /* FIXME */ 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) static int _is_string_empty(char * string)
{ {
return *string == '\0' ? 1 : 0; return *string == '\0' ? 1 : 0;