Logo Search packages:      
Sourcecode: rapple version File versions  Download package

static int fs_dir_stat ( rpl_c_str_t  pathname  )  [static]

Stat the directory indicated by pathname. Intended to query the filesystem when deciding whether or not to create a directory.

Parameters:
pathname 
Returns:
-1 on error, 0 on success.

Definition at line 116 of file fsutil.c.

References rpl_log_fatal(), and rpl_message_get().

Referenced by rpl_fs_mkdir().

                                  {
    struct stat stbuf;

    assert(pathname != NULL);

    /* if the pathname does not exist return to the caller */
    if(lstat(pathname, &stbuf)<0)
        return -1;

    /* if directory already exists then notify the caller */
    if(S_ISDIR(stbuf.st_mode))
        return 0;

    /* if an existing entity already exists then fail entirely */
    if(S_ISREG(stbuf.st_mode) || S_ISLNK(stbuf.st_mode))
        rpl_log_fatal(rpl_message_get("FS_MKDIR_REG_FILE_FAILED", pathname, RPL_EOM));
    if(S_ISCHR(stbuf.st_mode) || S_ISBLK(stbuf.st_mode) || S_ISFIFO(stbuf.st_mode) || S_ISSOCK(stbuf.st_mode))
        rpl_log_fatal(rpl_message_get("FS_MKDIR_DV_FAILED", pathname, RPL_EOM));
    /* return at least an indication of error (all avoids -Wall complaints) */
    return -1;
}


Generated by  Doxygen 1.6.0   Back to index