Ejemplo n.º 1
0
FILE *ffms_fopen(const char *filename, const char *mode) {
#ifdef _WIN32
	std::wstring filename_wide = widen_path(filename);
	std::wstring mode_wide     = widen_path(mode);
	if (filename_wide.size() && mode_wide.size())
		return _wfopen(filename_wide.c_str(), mode_wide.c_str());
	else
		return fopen(filename, mode);
#else
	return fopen(filename, mode);
#endif /* _WIN32 */
}
Ejemplo n.º 2
0
int vlc_open (const char *filename, int flags, ...)
{
    int mode = 0;
    va_list ap;

    flags |= O_NOINHERIT; /* O_CLOEXEC */
    /* Defaults to binary mode */
    if ((flags & O_TEXT) == 0)
        flags |= O_BINARY;

    va_start (ap, flags);
    if (flags & O_CREAT)
        mode = va_arg (ap, int);
    va_end (ap);

    /*
     * open() cannot open files with non-“ANSI” characters on Windows.
     * We use _wopen() instead. Same thing for mkdir() and stat().
     */
    wchar_t *wpath = widen_path (filename);
    if (wpath == NULL)
        return -1;

    int fd = _wopen (wpath, flags, mode);
    free (wpath);
    return fd;
}
Ejemplo n.º 3
0
int vlc_open (const char *filename, int flags, ...)
{
    unsigned int mode = 0;
    va_list ap;

    va_start (ap, flags);
    if (flags & O_CREAT)
        mode = va_arg (ap, unsigned int);
    va_end (ap);

    /* Defaults to binary mode */
    if ((flags & O_TEXT) == 0)
        flags |= O_BINARY;

#ifdef UNDER_CE
    /*_open translates to wchar internally on WinCE*/
    return _open (filename, flags, mode);
#else
    /*
     * open() cannot open files with non-“ANSI” characters on Windows.
     * We use _wopen() instead. Same thing for mkdir() and stat().
     */
    wchar_t *wpath = widen_path (filename);
    if (wpath == NULL)
        return -1;

    int fd = _wopen (wpath, flags, mode);
    free (wpath);
    return fd;
#endif
}
Ejemplo n.º 4
0
DIR *vlc_opendir (const char *dirname)
{
    wchar_t *wpath = widen_path (dirname);
    if (wpath == NULL)
        return NULL;

    vlc_DIR *p_dir = malloc (sizeof (*p_dir));
    if (unlikely(p_dir == NULL))
    {
        free(wpath);
        return NULL;
    }

    if (wpath[0] == L'\0' || (wcscmp (wpath, L"\\") == 0))
    {
        free (wpath);
        /* Special mode to list drive letters */
        p_dir->wdir = NULL;
        p_dir->u.drives = GetLogicalDrives ();
        return (void *)p_dir;
    }

    assert (wpath[0]); // wpath[1] is defined
    p_dir->u.insert_dot_dot = !wcscmp (wpath + 1, L":\\");

    _WDIR *wdir = _wopendir (wpath);
    free (wpath);
    if (wdir == NULL)
    {
        free (p_dir);
        return NULL;
    }
    p_dir->wdir = wdir;
    return (void *)p_dir;
}
Ejemplo n.º 5
0
int vlc_mkdir( const char *dirname, mode_t mode )
{
    wchar_t *wpath = widen_path (dirname);
    if (wpath == NULL)
        return -1;

    int ret = _wmkdir (wpath);
    free (wpath);
    (void) mode;
    return ret;
}
Ejemplo n.º 6
0
// ffms_fstream stuff
ffms_fstream::ffms_fstream(const char *filename, std::ios_base::openmode mode)
#ifdef __MINGW32__
: filebuf(_wopen(widen_path(filename).c_str(), open_flags(mode), 0666), mode)
#endif
{
#if defined(_WIN32)

#ifndef __MINGW32__
	std::wstring filename_wide = widen_path(filename);
	if (filename_wide.size())
		open(filename_wide.c_str(), mode);
	else
		open(filename, mode);
#else
	// Unlike MSVC, mingw's iostream library doesn't have an fstream overload
	// that takes a wchar_t* filename, so instead we use gcc's nonstandard
	// fd wrapper
	std::iostream::rdbuf(&filebuf);
#endif //__MINGW32__

#else // _WIN32
	open(filename, mode);
#endif // _WIN32
}
Ejemplo n.º 7
0
int vlc_mkdir( const char *dirname, mode_t mode )
{
#if defined (UNDER_CE)
    (void) mode;
    /* mkdir converts internally to wchar */
    return _mkdir(dirname);
#else
    wchar_t *wpath = widen_path (dirname);
    if (wpath == NULL)
        return -1;

    int ret = _wmkdir (wpath);
    free (wpath);
    (void) mode;
    return ret;
#endif
}