diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-04-13 23:30:26 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-05-05 21:46:30 +0200 |
| commit | 9fb1f4d59aa56c0f04a43ad83c152eaa12600e74 (patch) | |
| tree | 7185cb634b18d9bde7fe4d976f69d07bb7a61888 /src | |
| parent | 6387446a183cf99803beb1bc68af8788601b73ce (diff) | |
Add ::take().
Diffstat (limited to 'src')
| -rw-r--r-- | src/file.cc | 9 | ||||
| -rw-r--r-- | src/file.h | 9 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/file.cc b/src/file.cc index 8759c7c1..f7c865b2 100644 --- a/src/file.cc +++ b/src/file.cc @@ -134,6 +134,15 @@ File::checked_read(void* ptr, size_t size) } +FILE* +File::take() +{ + auto give = _file; + _file = nullptr; + return give; +} + + /** Windows can't "by default" cope with paths longer than 260 characters, so if you pass such a path to * any boost::filesystem method it will fail. There is a "fix" for this, which is to prepend * the string \\?\ to the path. This will make it work, so long as: @@ -72,6 +72,15 @@ public: */ void close(); + boost::filesystem::path path() const { + return _path; + } + + /** Take ownership of the underlying FILE*; + * the File object will not closed it after this call. + */ + FILE* take(); + private: boost::filesystem::path _path; FILE* _file = nullptr; |
