diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-01-28 11:34:23 +0000 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-01-31 12:08:41 +0100 |
commit | 45c15e1112e03b8b211ed0968ed1b16d5ed4ddfe (patch) | |
tree | 50bed049e2a2dfc7a36504d7f787a0943a8777cd /hwpfilter | |
parent | e95d5d5666505cb05e9660f24f6c7ae039451ef8 (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>
Diffstat (limited to 'hwpfilter')
-rw-r--r-- | hwpfilter/source/htags.cxx | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/hwpfilter/source/htags.cxx b/hwpfilter/source/htags.cxx index b8cafcf38675..4644d286d75c 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 |