aboutsummaryrefslogtreecommitdiffstats
path: root/src/platforms
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2012-04-16 22:32:33 +0200
committerVincent Richard <[email protected]>2012-04-16 22:32:33 +0200
commit4f33877820edee1b47d1b6f4fc800eaad273adaa (patch)
tree10d5d339f17f2561ef46993de308c2e7d8a9fd79 /src/platforms
parentSplit stream.hpp/.cpp into multiple source files. (diff)
downloadvmime-4f33877820edee1b47d1b6f4fc800eaad273adaa.tar.gz
vmime-4f33877820edee1b47d1b6f4fc800eaad273adaa.zip
Added ability to parse directly from an input stream (eg. file). This allows very big messages to be parsed without loading the whole message data into memory.
Diffstat (limited to 'src/platforms')
-rw-r--r--src/platforms/posix/posixFile.cpp20
-rw-r--r--src/platforms/windows/windowsFile.cpp18
2 files changed, 38 insertions, 0 deletions
diff --git a/src/platforms/posix/posixFile.cpp b/src/platforms/posix/posixFile.cpp
index ec529eb6..4087a21f 100644
--- a/src/platforms/posix/posixFile.cpp
+++ b/src/platforms/posix/posixFile.cpp
@@ -224,6 +224,26 @@ vmime::utility::stream::size_type posixFileReaderInputStream::skip(const size_ty
}
+vmime::utility::stream::size_type posixFileReaderInputStream::getPosition() const
+{
+ const off_t curPos = ::lseek(m_fd, 0, SEEK_CUR);
+
+ if (curPos == off_t(-1))
+ posixFileSystemFactory::reportError(m_path, errno);
+
+ return static_cast <size_type>(curPos);
+}
+
+
+void posixFileReaderInputStream::seek(const size_type pos)
+{
+ const off_t newPos = ::lseek(m_fd, pos, SEEK_SET);
+
+ if (newPos == off_t(-1))
+ posixFileSystemFactory::reportError(m_path, errno);
+}
+
+
//
// posixFileWriter
diff --git a/src/platforms/windows/windowsFile.cpp b/src/platforms/windows/windowsFile.cpp
index 624612af..5da786e5 100644
--- a/src/platforms/windows/windowsFile.cpp
+++ b/src/platforms/windows/windowsFile.cpp
@@ -479,6 +479,24 @@ vmime::utility::stream::size_type windowsFileReaderInputStream::skip(const size_
return (dwNewPos - dwCurPos);
}
+vmime::utility::stream::size_type windowsFileReaderInputStream::getPosition() const
+{
+ DWORD dwCurPos = SetFilePointer(m_hFile, 0, NULL, FILE_CURRENT);
+
+ if (dwCurPos == INVALID_SET_FILE_POINTER)
+ windowsFileSystemFactory::reportError(m_path, GetLastError());
+
+ return static_cast <size_type>(dwCurPos);
+}
+
+void windowsFileReaderInputStream::seek(const size_type pos)
+{
+ DWORD dwNewPos = SetFilePointer(m_hFile, (LONG)pos, NULL, FILE_BEGIN);
+
+ if (dwNewPos == INVALID_SET_FILE_POINTER)
+ windowsFileSystemFactory::reportError(m_path, GetLastError());
+}
+
windowsFileWriter::windowsFileWriter(const vmime::utility::file::path& path, const vmime::string& nativePath)
: m_path(path), m_nativePath(nativePath)
{