summaryrefslogtreecommitdiff
path: root/include/lldb/Host/File.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/lldb/Host/File.h')
-rw-r--r--include/lldb/Host/File.h82
1 files changed, 43 insertions, 39 deletions
diff --git a/include/lldb/Host/File.h b/include/lldb/Host/File.h
index 5747cb5adcfde..27f3f405ffd37 100644
--- a/include/lldb/Host/File.h
+++ b/include/lldb/Host/File.h
@@ -9,12 +9,15 @@
#ifndef liblldb_File_h_
#define liblldb_File_h_
-#if defined(__cplusplus)
+// C Includes
+// C++ Includes
#include <stdarg.h>
#include <stdio.h>
#include <sys/types.h>
+// Other libraries and framework includes
+// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Host/IOObject.h"
@@ -73,13 +76,11 @@ public:
File (const File &rhs);
- File &
- operator= (const File &rhs);
//------------------------------------------------------------------
/// Constructor with path.
///
/// Takes a path to a file which can be just a filename, or a full
- /// path. If \a path is not NULL or empty, this function will call
+ /// path. If \a path is not nullptr or empty, this function will call
/// File::Open (const char *path, uint32_t options, uint32_t permissions).
///
/// @param[in] path
@@ -101,10 +102,10 @@ public:
/// Constructor with FileSpec.
///
/// Takes a FileSpec pointing to a file which can be just a filename, or a full
- /// path. If \a path is not NULL or empty, this function will call
+ /// path. If \a path is not nullptr or empty, this function will call
/// File::Open (const char *path, uint32_t options, uint32_t permissions).
///
- /// @param[in] path
+ /// @param[in] filespec
/// The FileSpec for this file.
///
/// @param[in] options
@@ -124,7 +125,9 @@ public:
m_descriptor (fd),
m_stream (kInvalidStream),
m_options (0),
- m_own_stream (false)
+ m_own_stream (false),
+ m_is_interactive (eLazyBoolCalculate),
+ m_is_real_terminal (eLazyBoolCalculate)
{
}
@@ -133,11 +136,13 @@ public:
///
/// The destructor is virtual in case this class is subclassed.
//------------------------------------------------------------------
- virtual
- ~File ();
+ ~File() override;
+
+ File &
+ operator= (const File &rhs);
bool
- IsValid () const
+ IsValid() const override
{
return DescriptorIsValid() || StreamIsValid();
}
@@ -156,7 +161,7 @@ public:
///
/// @return
/// A pointer to this object if either the directory or filename
- /// is valid, NULL otherwise.
+ /// is valid, nullptr otherwise.
//------------------------------------------------------------------
operator
bool () const
@@ -216,7 +221,7 @@ public:
uint32_t permissions = lldb::eFilePermissionsFileDefault);
Error
- Close ();
+ Close() override;
Error
Duplicate (const File &rhs);
@@ -225,8 +230,7 @@ public:
GetDescriptor() const;
WaitableHandle
- GetWaitableHandle();
-
+ GetWaitableHandle() override;
void
SetDescriptor(int fd, bool transfer_ownership);
@@ -247,7 +251,7 @@ public:
/// @param[in] buf
/// A buffer where to put the bytes that are read.
///
- /// @param[in/out] num_bytes
+ /// @param[in,out] num_bytes
/// The number of bytes to read form the current file position
/// which gets modified with the number of bytes that were read.
///
@@ -256,7 +260,7 @@ public:
/// failure.
//------------------------------------------------------------------
Error
- Read (void *buf, size_t &num_bytes);
+ Read(void *buf, size_t &num_bytes) override;
//------------------------------------------------------------------
/// Write bytes to a file at the current file position.
@@ -268,7 +272,7 @@ public:
/// @param[in] buf
/// A buffer where to put the bytes that are read.
///
- /// @param[in/out] num_bytes
+ /// @param[in,out] num_bytes
/// The number of bytes to write to the current file position
/// which gets modified with the number of bytes that were
/// written.
@@ -278,7 +282,7 @@ public:
/// failure.
//------------------------------------------------------------------
Error
- Write (const void *buf, size_t &num_bytes);
+ Write(const void *buf, size_t &num_bytes) override;
//------------------------------------------------------------------
/// Seek to an offset relative to the beginning of the file.
@@ -295,13 +299,13 @@ public:
///
/// @param[in] error_ptr
/// A pointer to a lldb_private::Error object that will be
- /// filled in if non-NULL.
+ /// filled in if non-nullptr.
///
/// @return
/// The resulting seek offset, or -1 on error.
//------------------------------------------------------------------
off_t
- SeekFromStart (off_t offset, Error *error_ptr = NULL);
+ SeekFromStart(off_t offset, Error *error_ptr = nullptr);
//------------------------------------------------------------------
/// Seek to an offset relative to the current file position.
@@ -318,13 +322,13 @@ public:
///
/// @param[in] error_ptr
/// A pointer to a lldb_private::Error object that will be
- /// filled in if non-NULL.
+ /// filled in if non-nullptr.
///
/// @return
/// The resulting seek offset, or -1 on error.
//------------------------------------------------------------------
off_t
- SeekFromCurrent (off_t offset, Error *error_ptr = NULL);
+ SeekFromCurrent(off_t offset, Error *error_ptr = nullptr);
//------------------------------------------------------------------
/// Seek to an offset relative to the end of the file.
@@ -335,20 +339,20 @@ public:
/// @see File::Read (void *, size_t, off_t &)
/// @see File::Write (const void *, size_t, off_t &)
///
- /// @param[in/out] offset
+ /// @param[in,out] offset
/// The offset to seek to within the file relative to the
/// end of the file which gets filled in with the resulting
/// absolute file offset.
///
/// @param[in] error_ptr
/// A pointer to a lldb_private::Error object that will be
- /// filled in if non-NULL.
+ /// filled in if non-nullptr.
///
/// @return
/// The resulting seek offset, or -1 on error.
//------------------------------------------------------------------
off_t
- SeekFromEnd (off_t offset, Error *error_ptr = NULL);
+ SeekFromEnd(off_t offset, Error *error_ptr = nullptr);
//------------------------------------------------------------------
/// Read bytes from a file from the specified file offset.
@@ -357,14 +361,14 @@ public:
/// own file position markers and reads on other threads won't mess
/// up the current read.
///
- /// @param[in] buf
+ /// @param[in] dst
/// A buffer where to put the bytes that are read.
///
- /// @param[in/out] num_bytes
+ /// @param[in,out] num_bytes
/// The number of bytes to read form the current file position
/// which gets modified with the number of bytes that were read.
///
- /// @param[in/out] offset
+ /// @param[in,out] offset
/// The offset within the file from which to read \a num_bytes
/// bytes. This offset gets incremented by the number of bytes
/// that were read.
@@ -383,11 +387,11 @@ public:
/// own file position markers and reads on other threads won't mess
/// up the current read.
///
- /// @param[in/out] num_bytes
+ /// @param[in,out] num_bytes
/// The number of bytes to read form the current file position
/// which gets modified with the number of bytes that were read.
///
- /// @param[in/out] offset
+ /// @param[in,out] offset
/// The offset within the file from which to read \a num_bytes
/// bytes. This offset gets incremented by the number of bytes
/// that were read.
@@ -419,15 +423,15 @@ public:
/// their own locking externally to avoid multiple people writing
/// to the file at the same time.
///
- /// @param[in] buf
+ /// @param[in] src
/// A buffer containing the bytes to write.
///
- /// @param[in/out] num_bytes
+ /// @param[in,out] num_bytes
/// The number of bytes to write to the file at offset \a offset.
/// \a num_bytes gets modified with the number of bytes that
/// were read.
///
- /// @param[in/out] offset
+ /// @param[in,out] offset
/// The offset within the file at which to write \a num_bytes
/// bytes. This offset gets incremented by the number of bytes
/// that were written.
@@ -472,7 +476,6 @@ public:
static uint32_t
GetPermissions(const FileSpec &file_spec, Error &error);
-
//------------------------------------------------------------------
/// Return true if this file is interactive.
///
@@ -497,6 +500,9 @@ public:
//------------------------------------------------------------------
bool
GetIsRealTerminal ();
+
+ bool
+ GetIsTerminalWithColors ();
//------------------------------------------------------------------
/// Output printf formatted output to the stream.
@@ -516,15 +522,13 @@ public:
size_t
PrintfVarArg(const char *format, va_list args);
-
void
SetOptions (uint32_t options)
{
m_options = options;
}
+
protected:
-
-
bool
DescriptorIsValid () const
{
@@ -549,9 +553,9 @@ protected:
bool m_own_stream;
LazyBool m_is_interactive;
LazyBool m_is_real_terminal;
+ LazyBool m_supports_colors;
};
} // namespace lldb_private
-#endif // #if defined(__cplusplus)
-#endif // liblldb_File_h_
+#endif // liblldb_File_h_