diff options
author | Lawrence D'Anna <lawrence_danna@apple.com> | 2019-10-15 16:46:27 +0000 |
---|---|---|
committer | Lawrence D'Anna <lawrence_danna@apple.com> | 2019-10-15 16:46:27 +0000 |
commit | 28e783e3c3d31fa3a3203e103228cfb97008f4b9 (patch) | |
tree | 212fd7d8aac0d3259299e46713fb7121ce88dbd7 /source/Host | |
parent | de30a90cbc2fa2ce84112d81c7bea9d60655e7eb (diff) | |
download | lldb-28e783e3c3d31fa3a3203e103228cfb97008f4b9.tar.gz |
SBFile::GetFile: convert SBFile back into python native files.
Summary:
This makes SBFile::GetFile public and adds a SWIG typemap to convert
the result back into a python native file.
If the underlying File itself came from a python file, it is returned
identically. Otherwise a new python file object is created using
the file descriptor.
Reviewers: JDevlieghere, jasonmolenda, labath
Reviewed By: labath
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D68737
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@374911 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'source/Host')
-rw-r--r-- | source/Host/common/File.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/source/Host/common/File.cpp b/source/Host/common/File.cpp index 2b096abdf..0f335bd02 100644 --- a/source/Host/common/File.cpp +++ b/source/Host/common/File.cpp @@ -39,7 +39,8 @@ using namespace lldb; using namespace lldb_private; using llvm::Expected; -static Expected<const char *> GetStreamOpenModeFromOptions(uint32_t options) { +Expected<const char *> +File::GetStreamOpenModeFromOptions(File::OpenOptions options) { if (options & File::eOpenOptionAppend) { if (options & File::eOpenOptionRead) { if (options & File::eOpenOptionCanCreateNewOnly) @@ -226,6 +227,12 @@ size_t File::PrintfVarArg(const char *format, va_list args) { return result; } +Expected<File::OpenOptions> File::GetOptions() const { + return llvm::createStringError( + llvm::inconvertibleErrorCode(), + "GetOptions() not implemented for this File class"); +} + uint32_t File::GetPermissions(Status &error) const { int fd = GetDescriptor(); if (!DescriptorIsValid(fd)) { @@ -241,6 +248,8 @@ uint32_t File::GetPermissions(Status &error) const { return file_stats.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); } +Expected<File::OpenOptions> NativeFile::GetOptions() const { return m_options; } + int NativeFile::GetDescriptor() const { if (DescriptorIsValid()) return m_descriptor; @@ -758,3 +767,6 @@ mode_t File::ConvertOpenOptionsForPOSIXOpen(OpenOptions open_options) { return mode; } + +char File::ID = 0; +char NativeFile::ID = 0; |