summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/common
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-02-08 19:54:44 +0000
committerGreg Clayton <gclayton@apple.com>2011-02-08 19:54:44 +0000
commit846b64bf834dcfab0ad1404249cab4da7e5a3ea7 (patch)
treeb0bba9b252f4055226fd73da1fa62a77bc94e984 /lldb/source/Host/common
parent4d83c691f6ddf4f8a45150c2c789fc8b36bea616 (diff)
downloadbcm5719-llvm-846b64bf834dcfab0ad1404249cab4da7e5a3ea7.tar.gz
bcm5719-llvm-846b64bf834dcfab0ad1404249cab4da7e5a3ea7.zip
Updated a few more Host::File functions and added documentation.
llvm-svn: 125110
Diffstat (limited to 'lldb/source/Host/common')
-rw-r--r--lldb/source/Host/common/File.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp
index c95e08935d1..6bfb5d6d901 100644
--- a/lldb/source/Host/common/File.cpp
+++ b/lldb/source/Host/common/File.cpp
@@ -13,6 +13,7 @@
#include <fcntl.h>
#include "lldb/Core/Error.h"
+#include "lldb/Host/FileSpec.h"
using namespace lldb;
using namespace lldb_private;
@@ -186,6 +187,7 @@ File::Sync ()
}
return error;
}
+
Error
File::Read (void *buf, size_t &num_bytes)
{
@@ -232,3 +234,58 @@ File::Write (const void *buf, size_t &num_bytes)
return error;
}
+
+Error
+File::Read (void *buf, size_t &num_bytes, off_t &offset)
+{
+ Error error;
+ if (IsValid ())
+ {
+ ssize_t bytes_read = ::pread (m_file_desc, buf, num_bytes, offset);
+ if (bytes_read < 0)
+ {
+ num_bytes = 0;
+ error.SetErrorToErrno();
+ }
+ else
+ {
+ offset += bytes_read;
+ num_bytes = bytes_read;
+ }
+ }
+ else
+ {
+ num_bytes = 0;
+ error.SetErrorString("invalid file handle");
+ }
+ return error;
+}
+
+Error
+File::Write (const void *buf, size_t &num_bytes, off_t &offset)
+{
+ Error error;
+ if (IsValid())
+ {
+ ssize_t bytes_written = ::pwrite (m_file_desc, buf, num_bytes, offset);
+ if (bytes_written < 0)
+ {
+ num_bytes = 0;
+ error.SetErrorToErrno();
+ }
+ else
+ {
+ offset += bytes_written;
+ num_bytes = bytes_written;
+ }
+ }
+ else
+ {
+ num_bytes = 0;
+ error.SetErrorString("invalid file handle");
+ }
+ return error;
+}
+
+
+
OpenPOWER on IntegriCloud