代码如下:
#include <unistd.h>
int FindFile(const char *file)
{
/* Check for existence */
if( (access( file, 0 )) != -1 )
{
cm_printf(LOG_LEVEL_DEBUG, "File %s exists .", file );
/* Check for write permission */
if( (access( file, 2 )) != -1 )
{
cm_printf(LOG_LEVEL_DEBUG, "File %s has write permission ", file );
return 2;
}
return 1;
}
return 0;
}