1
1
forked from 0ad/0ad

Avoid apparent error on OS X by simplifying wopen API to avoid varargs.

Remove unused sys_wopen.

This was SVN commit r7384.
This commit is contained in:
Ykkrosh 2010-03-21 12:42:50 +00:00
parent 248749c1aa
commit 148ff026ca
5 changed files with 17 additions and 32 deletions

View File

@ -28,7 +28,6 @@
#include "lib/file/file.h"
#include "lib/file/common/file_stats.h"
#include "lib/sysdep/sysdep.h" // sys_wopen
ERROR_ASSOCIATE(ERR::FILE_ACCESS, L"Insufficient access rights to open file", EACCES);

View File

@ -74,7 +74,8 @@ extern int wclosedir(WDIR*);
#define O_NONBLOCK 0x1000000
#endif
extern int wopen(const wchar_t* pathname, int oflag, ...);
extern int wopen(const wchar_t* pathname, int oflag);
extern int wopen(const wchar_t* pathname, int oflag, mode_t mode);
extern int wclose(int fd);

View File

@ -68,17 +68,15 @@ int wclosedir(WDIR* wd)
}
int wopen(const wchar_t* pathname, int oflag, ...)
int wopen(const wchar_t* pathname, int oflag)
{
mode_t mode = S_IRWXG|S_IRWXO|S_IRWXU;
if(oflag & O_CREAT)
{
va_list args;
va_start(args, oflag);
mode = va_arg(args, mode_t);
va_end(args);
}
debug_assert(!(oflag & O_CREAT));
fs::path pathname_c(path_from_wpath(pathname));
return open(pathname_c.string().c_str(), oflag);
}
int wopen(const wchar_t* pathname, int oflag, mode_t mode)
{
fs::path pathname_c(path_from_wpath(pathname));
return open(pathname_c.string().c_str(), oflag, mode);
}

View File

@ -177,20 +177,6 @@ LibError sys_cursor_free(sys_cursor cursor)
return INFO::OK;
}
int sys_wopen(const wchar_t* pathname, int oflag, ...)
{
mode_t mode = 0;
if(oflag & O_CREAT)
{
va_list args;
va_start(args, oflag);
mode = va_arg(args, mode_t);
va_end(args);
}
return open(utf8_from_wstring(pathname).c_str(), oflag, mode);
}
// note: just use the sector size: Linux aio doesn't really care about
// the alignment of buffers/lengths/offsets, so we'll just pick a
// sane value and not bother scanning all drives.

View File

@ -327,16 +327,17 @@ int wclosedir(WDIR* d)
// fcntl.h
//-----------------------------------------------------------------------------
int wopen(const wchar_t* pathname, int oflag, ...)
int wopen(const wchar_t* pathname, int oflag)
{
debug_assert(!(oflag & O_CREAT));
return wopen(pathname, oflag, _S_IREAD|_S_IWRITE);
}
int wopen(const wchar_t* pathname, int oflag, mode_t mode_arg)
{
mode_t mode = _S_IREAD|_S_IWRITE;
if(oflag & O_CREAT)
{
va_list args;
va_start(args, oflag);
mode = va_arg(args, mode_t);
va_end(args);
}
mode = mode_arg;
WinScopedPreserveLastError s; // _wsopen_s's CreateFileW
int fd;