diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
commit | 267c6f2ac71f92999e969232431ba04678e7437e (patch) | |
tree | 358c9467650e1d0a1d7227a21dac2e3d08b622b2 /external/boost/boost.file_iterator.sharing_win.patch | |
parent | Initial commit. (diff) | |
download | libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip |
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'external/boost/boost.file_iterator.sharing_win.patch')
-rw-r--r-- | external/boost/boost.file_iterator.sharing_win.patch | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/external/boost/boost.file_iterator.sharing_win.patch b/external/boost/boost.file_iterator.sharing_win.patch new file mode 100644 index 0000000000..b3b8bea3f3 --- /dev/null +++ b/external/boost/boost.file_iterator.sharing_win.patch @@ -0,0 +1,158 @@ +--- foo/misc/boost/boost/spirit/home/classic/iterator/impl/file_iterator.ipp.orig ++++ foo/misc/boost/boost/spirit/home/classic/iterator/impl/file_iterator.ipp +@@ -181,67 +181,28 @@ public: + {} + + explicit mmap_file_iterator(std::string const& fileName) +- : m_filesize(0), m_curChar(0) +- { +- HANDLE hFile = ::CreateFileA( ++ : mmap_file_iterator(::CreateFileA( + fileName.c_str(), + GENERIC_READ, +- FILE_SHARE_READ, ++ FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_FLAG_SEQUENTIAL_SCAN, + NULL +- ); +- +- if (hFile == INVALID_HANDLE_VALUE) +- return; +- +- // Store the size of the file, it's used to construct +- // the end iterator +- m_filesize = ::GetFileSize(hFile, NULL); ++ )) ++ {} + +- HANDLE hMap = ::CreateFileMapping( +- hFile, ++ explicit mmap_file_iterator(std::wstring const& fileName) ++ : mmap_file_iterator(::CreateFileW( ++ fileName.c_str(), ++ GENERIC_READ, ++ FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, +- PAGE_READONLY, +- 0, 0, ++ OPEN_EXISTING, ++ FILE_FLAG_SEQUENTIAL_SCAN, + NULL +- ); +- +- if (hMap == NULL) +- { +- ::CloseHandle(hFile); +- return; +- } +- +- LPVOID pMem = ::MapViewOfFile( +- hMap, +- FILE_MAP_READ, +- 0, 0, 0 +- ); +- +- if (pMem == NULL) +- { +- ::CloseHandle(hMap); +- ::CloseHandle(hFile); +- return; +- } +- +- // We hold both the file handle and the memory pointer. +- // We can close the hMap handle now because Windows holds internally +- // a reference to it since there is a view mapped. +- ::CloseHandle(hMap); +- +- // It seems like we can close the file handle as well (because +- // a reference is hold by the filemap object). +- ::CloseHandle(hFile); +- +- // Store the handles inside the shared_ptr (with the custom destructors) +- m_mem.reset(static_cast<CharT*>(pMem), ::UnmapViewOfFile); +- +- // Start of the file +- m_curChar = m_mem.get(); +- } ++ )) ++ {} + + mmap_file_iterator(const mmap_file_iterator& iter) + { *this = iter; } +@@ -290,6 +251,59 @@ private: + boost::shared_ptr<CharT> m_mem; + std::size_t m_filesize; + CharT* m_curChar; ++ ++ explicit mmap_file_iterator(HANDLE hFile) ++ : m_filesize(0), m_curChar(0) ++ { ++ if (hFile == INVALID_HANDLE_VALUE) ++ return; ++ ++ // Store the size of the file, it's used to construct ++ // the end iterator ++ m_filesize = ::GetFileSize(hFile, NULL); ++ ++ HANDLE hMap = ::CreateFileMapping( ++ hFile, ++ NULL, ++ PAGE_READONLY, ++ 0, 0, ++ NULL ++ ); ++ ++ if (hMap == NULL) ++ { ++ ::CloseHandle(hFile); ++ return; ++ } ++ ++ LPVOID pMem = ::MapViewOfFile( ++ hMap, ++ FILE_MAP_READ, ++ 0, 0, 0 ++ ); ++ ++ if (pMem == NULL) ++ { ++ ::CloseHandle(hMap); ++ ::CloseHandle(hFile); ++ return; ++ } ++ ++ // We hold both the file handle and the memory pointer. ++ // We can close the hMap handle now because Windows holds internally ++ // a reference to it since there is a view mapped. ++ ::CloseHandle(hMap); ++ ++ // It seems like we can close the file handle as well (because ++ // a reference is hold by the filemap object). ++ ::CloseHandle(hFile); ++ ++ // Store the handles inside the shared_ptr (with the custom destructors) ++ m_mem.reset(static_cast<CharT*>(pMem), ::UnmapViewOfFile); ++ ++ // Start of the file ++ m_curChar = m_mem.get(); ++ } + }; + + #endif // BOOST_SPIRIT_FILEITERATOR_WINDOWS +--- foo/misc/boost/boost/spirit/home/classic/iterator/file_iterator.hpp.orig ++++ foo/misc/boost/boost/spirit/home/classic/iterator/file_iterator.hpp +@@ -170,6 +170,12 @@ public: + : base_t(adapted_t(fileName)) + {} + ++#ifdef BOOST_SPIRIT_FILEITERATOR_WINDOWS ++ file_iterator(std::wstring const& fileName) ++ : base_t(adapted_t(fileName)) ++ {} ++#endif ++ + file_iterator(const base_t& iter) + : base_t(iter) + {} |