fs/FileSystem: OpenFile() returns UniqueFileDescriptor

This commit is contained in:
Max Kellermann
2017-08-10 19:32:17 +02:00
parent eb0ff32efb
commit df5cc3f0f6
5 changed files with 13 additions and 16 deletions

View File

@@ -22,6 +22,7 @@
#include "AllocatedPath.hxx"
#include "Limits.hxx"
#include "system/Error.hxx"
#include "system/fd_util.h"
#include <errno.h>
#include <fcntl.h>

View File

@@ -22,9 +22,8 @@
#include "check.h"
#include "Traits.hxx"
#include "system/fd_util.h"
#include "Path.hxx"
#include "system/UniqueFileDescriptor.hxx"
#ifdef WIN32
#include <fileapi.h>
@@ -53,14 +52,12 @@ FOpen(Path file, PathTraitsFS::const_pointer_type mode)
/**
* Wrapper for open_cloexec() that uses #Path names.
*/
static inline int
static inline UniqueFileDescriptor
OpenFile(Path file, int flags, int mode)
{
#ifdef WIN32
return _topen(file.c_str(), flags, mode);
#else
return open_cloexec(file.c_str(), flags, mode);
#endif
UniqueFileDescriptor fd;
fd.Open(file.c_str(), flags, mode);
return fd;
}
/*