ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

int compat_open ( const char filename,
int  mode 
)

Opening a file handle can be different. This function here is defined to take a path in native encoding (ISO8859 / UTF-8 / ...), or, when MS Windows Unicode support is enabled, an UTF-8 string that will be converted back to native UCS-2 (wide character) before calling the system's open function.

Parameters:
[in]wptrPointer to wide string.
[in]mbptrPointer to multibyte string.
Returns:
file descriptor (>=0) or error code.

Definition at line 58 of file compat.c.

Referenced by mpg123_open(), and open_stream().

{
    int ret;
#if defined (WANT_WIN32_UNICODE)
    const wchar_t *frag = NULL;

    ret = win32_utf8_wide(filename, &frag, NULL);
    if ((frag == NULL) || (ret == 0)) goto fallback; /* Fallback to plain open when ucs-2 conversion fails */

    ret = _wopen(frag, mode); /*Try _wopen */
    if (ret != -1 ) goto open_ok; /* msdn says -1 means failure */

fallback:
#endif

#ifdef __MSVCRT__ /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */
    ret = _open (filename, mode); /* Try plain old _open(), if it fails, do nothing */
#else
    ret = open (filename, mode);
#endif

#if defined (WANT_WIN32_UNICODE)
open_ok:
    free ((void *)frag); /* Freeing a NULL should be OK */
#endif

    return ret;
}

Generated on Sun May 27 2012 05:08:46 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.