Status ResolveSymbolicLink(const FileSpec &src, FileSpec &dst);
- /// Wraps ::fopen in a platform-independent way. Once opened, FILEs can be
- /// manipulated and closed with the normal ::fread, ::fclose, etc. functions.
+ /// Wraps ::fopen in a platform-independent way.
FILE *Fopen(const char *path, const char *mode);
+ /// Wraps ::open in a platform-independent way.
+ int Open(const char *path, int flags, int mode);
+
/// Returns the modification time of the given file.
/// @{
llvm::sys::TimePoint<> GetModificationTime(const FileSpec &file_spec) const;
#include "llvm/Support/Process.h" // for llvm::sys::Process::FileDescriptorHasColors()
#include "lldb/Host/Config.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/FileSpec.h"
}
static int DoOpen(const char *path, int flags, int mode) {
-#ifdef _MSC_VER
- std::wstring wpath;
- if (!llvm::ConvertUTF8toWide(path, wpath))
- return -1;
- int result;
- ::_wsopen_s(&result, wpath.c_str(), flags, _SH_DENYNO, mode);
- return result;
-#else
- return ::open(path, flags, mode);
-#endif
+ return FileSystem::Instance().Open(path, flags, mode);
}
Status File::Open(const char *path, uint32_t options, uint32_t permissions) {
// C includes
#include <dirent.h>
+#include <fcntl.h>
#include <sys/mount.h>
#include <sys/param.h>
#include <sys/stat.h>
FILE *FileSystem::Fopen(const char *path, const char *mode) {
return ::fopen(path, mode);
}
+
+int FileSystem::Open(const char *path, int flags, int mode) {
+ return ::open(path, flags, mode);
+}
return nullptr;
return file;
}
+
+int FileSystem::Open(const char *path, int flags, int mode) {
+ std::wstring wpath;
+ if (!llvm::ConvertUTF8toWide(path, wpath))
+ return -1;
+ int result;
+ ::_wsopen_s(&result, wpath.c_str(), flags, _SH_DENYNO, mode);
+ return result;
+}