include/tools/stream.hxx | 3 ++- tools/source/stream/strmwnt.cxx | 7 ++++++- unotools/source/ucbhelper/tempfile.cxx | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-)
New commits: commit 27960861a66d13a3f0bb3ff8503bc9fdb53745da Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Tue Feb 18 18:54:43 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Feb 19 09:14:31 2020 +0100 use FILE_ATTRIBUTE_TEMPORARY on Windows for temp files which acts as a hint to the OS that these files do not need persistent storage. If there is sufficient system RAM, these files will never even hit disk. Change-Id: I25b83aad67fda58ec39cead8bd1eb038892d3cde Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88124 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx index 0f17c37c4958..2e8fbc6771b5 100644 --- a/include/tools/stream.hxx +++ b/include/tools/stream.hxx @@ -48,6 +48,7 @@ enum class StreamMode { NOCREATE = 0x0004, ///< 1 == Don't create file TRUNC = 0x0008, ///< Truncate _existing_ file to zero length COPY_ON_SYMLINK = 0x0010, ///< copy-on-write for symlinks (Unix) + TEMPORARY = 0x0020, ///< temporary file attribute (Windows) // sharing options SHARE_DENYNONE = 0x0100, SHARE_DENYREAD = 0x0200, // overrides denynone @@ -61,7 +62,7 @@ enum class StreamMode { }; namespace o3tl { - template<> struct typed_flags<StreamMode> : is_typed_flags<StreamMode, 0x0f1f> {}; + template<> struct typed_flags<StreamMode> : is_typed_flags<StreamMode, 0x0f3f> {}; } #define STREAM_SEEK_TO_BEGIN 0L diff --git a/tools/source/stream/strmwnt.cxx b/tools/source/stream/strmwnt.cxx index 23fa71526447..d85ce3a0c372 100644 --- a/tools/source/stream/strmwnt.cxx +++ b/tools/source/stream/strmwnt.cxx @@ -300,13 +300,18 @@ void SvFileStream::Open( const OUString& rFilename, StreamMode nMode ) nOpenAction = OPEN_EXISTING; } + DWORD nAttributes = FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS; + + if ( nMode & StreamMode::TEMPORARY ) + nAttributes |= FILE_ATTRIBUTE_TEMPORARY; + pInstanceData->hFile = CreateFileW( o3tl::toW(aFilename.getStr()), nAccessMode, nShareMode, nullptr, nOpenAction, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, + nAttributes, nullptr ); diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx index afda12972ac0..f6d66bdc33b6 100644 --- a/unotools/source/ucbhelper/tempfile.cxx +++ b/unotools/source/ucbhelper/tempfile.cxx @@ -420,7 +420,7 @@ SvStream* TempFile::GetStream( StreamMode eMode ) if (!pStream) { if (!aName.isEmpty()) - pStream.reset(new SvFileStream(aName, eMode)); + pStream.reset(new SvFileStream(aName, eMode | StreamMode::TEMPORARY)); else pStream.reset(new SvMemoryStream(nullptr, 0, eMode)); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits