diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/stream/stream.cxx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index fe2470766be3..84dcef93bcd5 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -37,6 +37,7 @@ #include <tools/long.hxx> #include <comphelper/fileformat.h> +#include <comphelper/fileurl.hxx> static void swapNibbles(unsigned char &c) { @@ -1414,6 +1415,25 @@ bool checkSeek(SvStream &rSt, sal_uInt64 nOffset) return (nOffset <= nMaxSeek && rSt.Seek(nOffset) == nOffset); } +namespace tools +{ +bool isEmptyFileUrl(const OUString& rUrl) +{ + if (!comphelper::isFileUrl(rUrl)) + { + return false; + } + + SvFileStream aStream(rUrl, StreamMode::READ); + if (!aStream.IsOpen()) + { + return false; + } + + return aStream.remainingSize() == 0; +} +} + //STREAM_SEEK_TO_END in some of the Seek backends is special cased to be //efficient, in others e.g. SotStorageStream it's really horribly slow, and in //those this should be overridden |