diff options
-rw-r--r-- | include/tools/stream.hxx | 3 | ||||
-rw-r--r-- | tools/source/stream/strmwnt.cxx | 7 | ||||
-rw-r--r-- | unotools/source/ucbhelper/tempfile.cxx | 2 |
3 files changed, 9 insertions, 3 deletions
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)); } |