Ejemplo n.º 1
0
/*
 * This function is supposed to be for backward compatibility with
 * nspr 1.0.  Therefore, it still uses the nspr 1.0 error-reporting
 * mechanism -- returns a PRInt32, which is the error code when the call
 * fails.
 * 
 * If we need this function in nspr 2.0, it should be changed to
 * return PRStatus, as follows:
 *
 * PR_IMPLEMENT(PRStatus) PR_Stat(const char *name, struct stat *buf)
 * {
 *     PRInt32 rv;
 *
 *     rv = _PR_MD_STAT(name, buf);
 *     if (rv < 0)
 *         return PR_FAILURE;
 *     else
 *         return PR_SUCCESS;
 * }
 *
 * -- wtc, 2/14/97.
 */
PR_IMPLEMENT(PRInt32) PR_Stat(const char *name, struct stat *buf)
{
    PRInt32 rv;

    rv = _PR_MD_STAT(name, buf);
	return rv;
}
Ejemplo n.º 2
0
PRInt32
_PR_MD_GETFILEINFO(const char *fn, PRFileInfo *info)
{
    struct stat sb;
    PRInt32 rv;
    PRInt64 s, s2us;
 
    if ( (rv = _PR_MD_STAT(fn, &sb)) == 0 ) {
        if (info) {
            if (S_IFREG & sb.st_mode)
                info->type = PR_FILE_FILE ;
            else if (S_IFDIR & sb.st_mode)
                info->type = PR_FILE_DIRECTORY;
            else
                info->type = PR_FILE_OTHER;
            info->size = sb.st_size;
            LL_I2L(s2us, PR_USEC_PER_SEC);
            LL_I2L(s, sb.st_mtime);
            LL_MUL(s, s, s2us);
            info->modifyTime = s;
            LL_I2L(s, sb.st_ctime);
            LL_MUL(s, s, s2us);
            info->creationTime = s;
        }
    }
    return rv;
}