Move to_platform_open_mode() to stat_util.cpp/h and made it available to other source files. It has little to do with stat data, but it fits with the other conversion functions at least and I found no better place.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11682 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
6ce30cc809
commit
2c05bc8a8d
@ -43,6 +43,13 @@ to_platform_stat(const struct my_stat *myst, struct stat *st)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
to_platform_open_mode(int myMode)
|
||||
{
|
||||
return myMode;
|
||||
}
|
||||
|
||||
|
||||
#else // !__BEOS__
|
||||
|
||||
#ifndef S_ATTR_DIR
|
||||
@ -236,4 +243,44 @@ to_platform_stat(const struct my_stat *myst, struct stat *st)
|
||||
// st->st_crtime = myst->crtime;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
to_platform_open_mode(int myMode)
|
||||
{
|
||||
#define SET_OPEN_MODE_FLAG(flag, myFlag) \
|
||||
if (myMode & myFlag) \
|
||||
mode |= flag;
|
||||
|
||||
int mode = 0;
|
||||
|
||||
// the r/w mode
|
||||
switch (myMode & MY_O_RWMASK) {
|
||||
case MY_O_RDONLY:
|
||||
mode |= O_RDONLY;
|
||||
break;
|
||||
case MY_O_WRONLY:
|
||||
mode |= O_WRONLY;
|
||||
break;
|
||||
case MY_O_RDWR:
|
||||
mode |= O_RDWR;
|
||||
break;
|
||||
}
|
||||
|
||||
// the flags
|
||||
//SET_OPEN_MODE_FLAG(O_CLOEXEC, MY_O_CLOEXEC)
|
||||
SET_OPEN_MODE_FLAG(O_NONBLOCK, MY_O_NONBLOCK)
|
||||
SET_OPEN_MODE_FLAG(O_EXCL, MY_O_EXCL)
|
||||
SET_OPEN_MODE_FLAG(O_CREAT, MY_O_CREAT)
|
||||
SET_OPEN_MODE_FLAG(O_TRUNC, MY_O_TRUNC)
|
||||
SET_OPEN_MODE_FLAG(O_APPEND, MY_O_APPEND)
|
||||
SET_OPEN_MODE_FLAG(O_NOCTTY, MY_O_NOCTTY)
|
||||
SET_OPEN_MODE_FLAG(O_NOTRAVERSE, MY_O_NOTRAVERSE)
|
||||
//SET_OPEN_MODE_FLAG(O_TEXT, MY_O_TEXT)
|
||||
//SET_OPEN_MODE_FLAG(O_BINARY, MY_O_BINARY)
|
||||
|
||||
#undef SET_OPEN_MODE_FLAG
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
#endif // !__BEOS__
|
||||
|
@ -17,6 +17,8 @@ mode_t to_platform_mode(my_mode_t mode);
|
||||
void from_platform_stat(const struct stat *st, struct my_stat *myst);
|
||||
void to_platform_stat(const struct my_stat *myst, struct stat *st);
|
||||
|
||||
extern int to_platform_open_mode(int myMode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -265,46 +265,6 @@ writev_pos(int fd, fs_off_t _pos, struct iovec *iov, int count)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
to_platform_open_mode(int myMode)
|
||||
{
|
||||
#define SET_OPEN_MODE_FLAG(flag, myFlag) \
|
||||
if (myMode & myFlag) \
|
||||
mode |= flag;
|
||||
|
||||
int mode = 0;
|
||||
|
||||
// the r/w mode
|
||||
switch (myMode & MY_O_RWMASK) {
|
||||
case MY_O_RDONLY:
|
||||
mode |= O_RDONLY;
|
||||
break;
|
||||
case MY_O_WRONLY:
|
||||
mode |= O_WRONLY;
|
||||
break;
|
||||
case MY_O_RDWR:
|
||||
mode |= O_RDWR;
|
||||
break;
|
||||
}
|
||||
|
||||
// the flags
|
||||
//SET_OPEN_MODE_FLAG(O_CLOEXEC, MY_O_CLOEXEC)
|
||||
SET_OPEN_MODE_FLAG(O_NONBLOCK, MY_O_NONBLOCK)
|
||||
SET_OPEN_MODE_FLAG(O_EXCL, MY_O_EXCL)
|
||||
SET_OPEN_MODE_FLAG(O_CREAT, MY_O_CREAT)
|
||||
SET_OPEN_MODE_FLAG(O_TRUNC, MY_O_TRUNC)
|
||||
SET_OPEN_MODE_FLAG(O_APPEND, MY_O_APPEND)
|
||||
SET_OPEN_MODE_FLAG(O_NOCTTY, MY_O_NOCTTY)
|
||||
SET_OPEN_MODE_FLAG(O_NOTRAVERSE, MY_O_NOTRAVERSE)
|
||||
//SET_OPEN_MODE_FLAG(O_TEXT, MY_O_TEXT)
|
||||
//SET_OPEN_MODE_FLAG(O_BINARY, MY_O_BINARY)
|
||||
|
||||
#undef SET_OPEN_MODE_FLAG
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
|
||||
int build_platform_open(const char *pathname, int oflags, my_mode_t mode);
|
||||
|
||||
int
|
||||
|
Loading…
Reference in New Issue
Block a user