Bump version to 24.04.3.4
[LibreOffice.git] / external / boost / boost.file_iterator.sharing_win.patch
blobb3b8bea3f3ffac8af3495e9a56ad40e8f728c3c5
1 --- foo/misc/boost/boost/spirit/home/classic/iterator/impl/file_iterator.ipp.orig
2 +++ foo/misc/boost/boost/spirit/home/classic/iterator/impl/file_iterator.ipp
3 @@ -181,67 +181,28 @@ public:
4 {}
6 explicit mmap_file_iterator(std::string const& fileName)
7 - : m_filesize(0), m_curChar(0)
8 - {
9 - HANDLE hFile = ::CreateFileA(
10 + : mmap_file_iterator(::CreateFileA(
11 fileName.c_str(),
12 GENERIC_READ,
13 - FILE_SHARE_READ,
14 + FILE_SHARE_READ | FILE_SHARE_WRITE,
15 NULL,
16 OPEN_EXISTING,
17 FILE_FLAG_SEQUENTIAL_SCAN,
18 NULL
19 - );
21 - if (hFile == INVALID_HANDLE_VALUE)
22 - return;
24 - // Store the size of the file, it's used to construct
25 - // the end iterator
26 - m_filesize = ::GetFileSize(hFile, NULL);
27 + ))
28 + {}
30 - HANDLE hMap = ::CreateFileMapping(
31 - hFile,
32 + explicit mmap_file_iterator(std::wstring const& fileName)
33 + : mmap_file_iterator(::CreateFileW(
34 + fileName.c_str(),
35 + GENERIC_READ,
36 + FILE_SHARE_READ | FILE_SHARE_WRITE,
37 NULL,
38 - PAGE_READONLY,
39 - 0, 0,
40 + OPEN_EXISTING,
41 + FILE_FLAG_SEQUENTIAL_SCAN,
42 NULL
43 - );
45 - if (hMap == NULL)
46 - {
47 - ::CloseHandle(hFile);
48 - return;
49 - }
51 - LPVOID pMem = ::MapViewOfFile(
52 - hMap,
53 - FILE_MAP_READ,
54 - 0, 0, 0
55 - );
57 - if (pMem == NULL)
58 - {
59 - ::CloseHandle(hMap);
60 - ::CloseHandle(hFile);
61 - return;
62 - }
64 - // We hold both the file handle and the memory pointer.
65 - // We can close the hMap handle now because Windows holds internally
66 - // a reference to it since there is a view mapped.
67 - ::CloseHandle(hMap);
69 - // It seems like we can close the file handle as well (because
70 - // a reference is hold by the filemap object).
71 - ::CloseHandle(hFile);
73 - // Store the handles inside the shared_ptr (with the custom destructors)
74 - m_mem.reset(static_cast<CharT*>(pMem), ::UnmapViewOfFile);
76 - // Start of the file
77 - m_curChar = m_mem.get();
78 - }
79 + ))
80 + {}
82 mmap_file_iterator(const mmap_file_iterator& iter)
83 { *this = iter; }
84 @@ -290,6 +251,59 @@ private:
85 boost::shared_ptr<CharT> m_mem;
86 std::size_t m_filesize;
87 CharT* m_curChar;
89 + explicit mmap_file_iterator(HANDLE hFile)
90 + : m_filesize(0), m_curChar(0)
91 + {
92 + if (hFile == INVALID_HANDLE_VALUE)
93 + return;
95 + // Store the size of the file, it's used to construct
96 + // the end iterator
97 + m_filesize = ::GetFileSize(hFile, NULL);
99 + HANDLE hMap = ::CreateFileMapping(
100 + hFile,
101 + NULL,
102 + PAGE_READONLY,
103 + 0, 0,
104 + NULL
105 + );
107 + if (hMap == NULL)
109 + ::CloseHandle(hFile);
110 + return;
113 + LPVOID pMem = ::MapViewOfFile(
114 + hMap,
115 + FILE_MAP_READ,
116 + 0, 0, 0
117 + );
119 + if (pMem == NULL)
121 + ::CloseHandle(hMap);
122 + ::CloseHandle(hFile);
123 + return;
126 + // We hold both the file handle and the memory pointer.
127 + // We can close the hMap handle now because Windows holds internally
128 + // a reference to it since there is a view mapped.
129 + ::CloseHandle(hMap);
131 + // It seems like we can close the file handle as well (because
132 + // a reference is hold by the filemap object).
133 + ::CloseHandle(hFile);
135 + // Store the handles inside the shared_ptr (with the custom destructors)
136 + m_mem.reset(static_cast<CharT*>(pMem), ::UnmapViewOfFile);
138 + // Start of the file
139 + m_curChar = m_mem.get();
143 #endif // BOOST_SPIRIT_FILEITERATOR_WINDOWS
144 --- foo/misc/boost/boost/spirit/home/classic/iterator/file_iterator.hpp.orig
145 +++ foo/misc/boost/boost/spirit/home/classic/iterator/file_iterator.hpp
146 @@ -170,6 +170,12 @@ public:
147 : base_t(adapted_t(fileName))
150 +#ifdef BOOST_SPIRIT_FILEITERATOR_WINDOWS
151 + file_iterator(std::wstring const& fileName)
152 + : base_t(adapted_t(fileName))
153 + {}
154 +#endif
156 file_iterator(const base_t& iter)
157 : base_t(iter)