summaryrefslogtreecommitdiff
path: root/hwpfilter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-01-28 11:34:23 +0000
committerGabor Kelemen <kelemeng@ubuntu.com>2022-05-24 13:29:24 +0200
commitae0d89934302e3a371d5783f9d8af2da26a620bb (patch)
tree8849e6cf6083d3a3f1f45b1eb885b9ea74a3b181 /hwpfilter
parent72ea4f4983456a6801d49478ea74d603ce306f98 (diff)
use our own tempfile mechanism
Change-Id: Ie7853ea8bd083d1056872cfad4323ff6cede235f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129071 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> (cherry picked from commit 45c15e1112e03b8b211ed0968ed1b16d5ed4ddfe) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129758 (cherry picked from commit 63fcec3105b060cffde5e94fe688c8a59418e4c0)
Diffstat (limited to 'hwpfilter')
-rw-r--r--hwpfilter/source/htags.cxx26
1 files changed, 11 insertions, 15 deletions
diff --git a/hwpfilter/source/htags.cxx b/hwpfilter/source/htags.cxx
index 0c011731c1d4..359c15ae78bc 100644
--- a/hwpfilter/source/htags.cxx
+++ b/hwpfilter/source/htags.cxx
@@ -19,6 +19,9 @@
#include "precompile.h"
+#include <o3tl/char16_t2wchar_t.hxx>
+#include <unotools/tempfile.hxx>
+
#include <string.h>
#include "hwplib.h"
@@ -108,27 +111,20 @@ void OlePicture::Read(HWPFile & hwpf)
delete [] data;
return;
}
- FILE *fp;
- char tname[200];
- wchar_t wtname[200];
- tmpnam(tname);
- if (nullptr == (fp = fopen(tname, "wb")))
- {
- delete [] data;
- return;
- }
- fwrite(data, size, 1, fp);
+
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+
+ SvFileStream aOutputStream(aTempFile.GetURL(), StreamMode::WRITE);
+ aOutputStream.WriteBytes(data, size);
delete [] data;
- fclose(fp);
- MultiByteToWideChar(CP_ACP, 0, tname, -1, wtname, 200);
- if( StgOpenStorage(wtname, nullptr,
+ aOutputStream.Close();
+ if( StgOpenStorage(o3tl::toW(aTempFile.GetFileName().getStr()), nullptr,
STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_TRANSACTED,
nullptr, 0, &pis) != S_OK ) {
pis = nullptr;
- unlink(tname);
return;
}
- unlink(tname);
#else
hwpf.SkipBlock(size);
#endif