Ejemplo n.º 1
0
/*----------------------------------------------------------------------*
                               rtp_file_open
 *----------------------------------------------------------------------*/
int rtp_file_open (RTP_HANDLE  * fdPtr, const char * name, unsigned short flag, unsigned short mode)
{
long fileHandle;

#ifdef RTP_DEBUG
	int result;
    /* ----------------------------------- */
    /*  Clear the error state by setting   */
    /*  to 0.                              */
    /* ----------------------------------- */
    set_errno (0);
#endif

    name = (char *) _rtp_name_to_nativename((char *) name);
    fileHandle = (long) vf_open((PFCHAR) name, (word) _rtp_flag_to_operation(flag), (word) _rtp_mode_to_permission(mode));

    if (fileHandle == (-1))
    {
#ifdef RTP_DEBUG
        result = xn_getlasterror( );
        RTP_DEBUG_OUTPUT_STR("rtp_file_open: error returned ");
        RTP_DEBUG_OUTPUT_INT(result);
        RTP_DEBUG_OUTPUT_STR(".\n");
#endif
        return (-1);
    }
    *fdPtr = (RTP_HANDLE) fileHandle;
    return (0);
}
Ejemplo n.º 2
0
/*----------------------------------------------------------------------*
                               rtp_wfile_open
 *----------------------------------------------------------------------*/
int rtp_wfile_open (RTP_HANDLE  * fdPtr, const unsigned short * name, unsigned short flag, unsigned short mode)
{

#if (_WIN32_WINNT) >= 0x0400

long fileHandle;
int result;

#ifdef RTP_DEBUG
    /* ----------------------------------- */
    /*  Clear the error state by setting   */
    /*  to 0.                              */
    /* ----------------------------------- */
    SetLastError(0);
#endif

    name = (unsigned short *)_rtp_unicode_name_to_winname ((unsigned short *) name);
    fileHandle = (long) _wopen (name, _rtp_flag_to_operation(flag), _rtp_mode_to_permission(mode));

    if (fileHandle == (-1))
    {
        result = GetLastError();
        /* ----------------------------------- */
        /*  If trying to open a directory or   */
        /*  opening a read only file with      */
        /*  write privilages.  This can be     */
        /*  non-fatal if doing an open to      */
        /*  determine the existance of a       */
        /*  directory.                         */
        /* ----------------------------------- */
        if (result == ERROR_ACCESS_DENIED)
        {
#ifdef RTP_DEBUG
            RTP_DEBUG_OUTPUT_STR("rtp_wfile_open: non-fatal error returned ");
            RTP_DEBUG_OUTPUT_INT(result);
            RTP_DEBUG_OUTPUT_STR(".\n");
#endif
            return (-2);
        }
#ifdef RTP_DEBUG
        RTP_DEBUG_OUTPUT_STR("rtp_wfile_open: error returned ");
        RTP_DEBUG_OUTPUT_INT(result);
        RTP_DEBUG_OUTPUT_STR(".\n");
#endif
        return (-1);
    }
    *fdPtr = (RTP_HANDLE) fileHandle;
    return (0);

#endif
	return (-1);
}
Ejemplo n.º 3
0
/*----------------------------------------------------------------------*
                               rtp_file_open
 *----------------------------------------------------------------------*/
int rtp_file_open (RTP_HANDLE  * fdPtr, const char * name, unsigned short flag, unsigned short mode)
{
    int fileHandle;

#ifdef RTP_DEBUG
    /* ----------------------------------- */
    /*  Clear the error state by setting   */
    /*  to 0.                              */
    /* ----------------------------------- */
    errno = 0;
#endif

    fileHandle = open (name, _rtp_flag_to_operation(flag), _rtp_mode_to_permission(mode));

    if (fileHandle == (-1))
    {
        /* ----------------------------------- */
        /*  If trying to open a directory or   */
        /*  opening a read only file with      */
        /*  write privilages.  This can be     */
        /*  non-fatal if doing an open to      */
        /*  determine the existance of a       */
        /*  directory.                         */
        /* ----------------------------------- */
        if (errno == EACCES)
        {
#ifdef RTP_DEBUG
            RTP_DEBUG_OUTPUT_STR("rtp_file_open: non-fatal error returned ");
            RTP_DEBUG_OUTPUT_INT(errno);
            RTP_DEBUG_OUTPUT_STR(".\n");
#endif
            return (-2);
        }
#ifdef RTP_DEBUG
        RTP_DEBUG_OUTPUT_STR("rtp_file_open: error returned ");
        RTP_DEBUG_OUTPUT_INT(errno);
        RTP_DEBUG_OUTPUT_STR(".\n");
#endif
        return (-1);
    }
    /* Ignore RTP_FILE_S_HIDDEN, RTP_FILE_S_SYSTEM, and RTP_FILE_S_ARCHIVE. */

    *fdPtr = (RTP_HANDLE) fileHandle;
#ifdef RTP_DEBUG
    RTP_DEBUG_OUTPUT_STR("rtp_file_open: ");
    RTP_DEBUG_OUTPUT_STR("...success");
    RTP_DEBUG_OUTPUT_STR(".\n");
#endif
    return (0);
}
Ejemplo n.º 4
0
/*----------------------------------------------------------------------*
                               rtp_file_open
 *----------------------------------------------------------------------*/
int rtp_file_open (RTP_HANDLE  * fdPtr, const char * name, unsigned short flag, unsigned short mode)
{
PCFD fileHandle;
int result;

#ifdef RTP_DISPLAY_ERROR
    char error[32];

    /* ----------------------------------- */
    /*  Clear the error state by setting   */
    /*  to 0.                              */
    /* ----------------------------------- */
    errno = 0;
#endif

    fileHandle = open (name, _rtp_flag_to_operation(flag), _rtp_mode_to_permission(mode));

    if (fileHandle == (PCFD)(-1))
    {
        result = errno;
        /* ----------------------------------- */
        /*  If trying to open a directory or   */
        /*  opening a read only file with      */
        /*  write privilages.  This can be     */
        /*  non-fatal if doing an open to      */
        /*  determine the existance of a       */
        /*  directory.                         */
        /* ----------------------------------- */
        if (result == PEACCES)
        {
#ifdef RTP_DISPLAY_ERROR
            rtp_term_cputs("rtp_file_open: non-fatal error returned ");
            rtp_term_puts(rtp_ltoa(result, error, 10));
#endif
            return (-2);
        }
#ifdef RTP_DISPLAY_ERROR
        rtp_term_cputs("rtp_file_open: error returned ");
        rtp_term_puts(rtp_itoa(result, error, 10));
#endif
        return (-1);
    }
    *fdPtr = (RTP_HANDLE) fileHandle;
    return (0);
}