Hi Henri,
suggestion (otherwise we would also have 2 unused vars rc and ptr on all 
non-AS400 platforms):

int jk_file_exists(const char *f)
{
    if (f) {
        struct stat st;
        int rc;
#ifdef AS400
#define S_IFREG _S_IFREG
        char *ptr;
/**
 * i5/OS V5R4 expect filename in ASCII for fopen but required them in EBCDIC 
for stat()
 */
#ifdef AS400_UTF8
        ptr = (char *)malloc(strlen(f) + 1);
        jk_ascii2ebcdic((char *)f, ptr);
        rc = stat(ptr, &st);
        free(ptr);
#else /* AS400_UTF8 */
        rc = stat(f, &st);
#endif /* AS400_UTF8 */
#else /* AS400 */
        rc = stat(f, &st);
#endif /* AS400 */
        if ((0 == rc) && (st.st_mode & S_IFREG))
            return JK_TRUE;
    }

    return JK_FALSE;
}


Guenter.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to