mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #63] Temporary files on Windows #52
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#52
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @utelle on GitHub (Jul 6, 2016).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/63
Originally assigned to: @jmcnamara on GitHub.
This issue is somewhat related to issue #53, but that one has a misleading subject.
On Windows the current default implementation of
lxw_tmpfile(which usestmpfileunder the hood) can impose a real problem. According to the documentationtmpfilealways creates temporary files in the root directory. However, the root directory is not accessible for users without elevated rights. This makeslibxlsxwriterfail and results in zero-length Excel files.The alternative implementation might be ok on Linux systems, but doesn't work on Windows. And a hard-coded path isn't a good idea anyway.
In the meantime I implemented a Windows and MSVC specific solution and of course I can post it here.
Additionally you can find under the following link a generic implementation: An all-singing, all-dancing C function to create a temporary file. Maybe this could be a generic solution for creating temporary files.
@jmcnamara commented on GitHub (Jul 6, 2016):
Hi Ulrich,
That incredible piece of software engineering has been a thorn in my side for years. The Perl and Python versions of this library have options to override the default temp directory.
Yes. That might help someone else who is struggling with this problem.
I'm little reticent to include something like this but there may be no choice for Windows users. I'll look into adding it on a branch for testing and take it from there.
John
@utelle commented on GitHub (Jul 8, 2016):
Hi John,
sorry for the delay. I was busy in my job.
I'll try to provide a variant that might be usable not only with MSVC. Not sure whether I succeed. I'll post the code early next week.
In fact, my implementation is similar to the generic implementation I quoted - just without the unneeded bits and pieces.
@jmcnamara commented on GitHub (Jul 8, 2016):
No problem. We all have jobs and probably none of them relate to creating Excel files for a living.
I'm going to put together a branch with the above library as an optional make option on Unix and as the default on Windows. I'll ping you when I've implemented and tested it a bit. If it looks stable I'll merge it to master.
@jmcnamara commented on GitHub (Jul 10, 2016):
I've pushed a version using tmpfileplus as the default tmpfile handler to the following branch: https://github.com/jmcnamara/libxlsxwriter/tree/tmpfileplus
I need to add some more documentation and fix the Mac cocoapod files but if you get a chance you can test it to see if it works for you.
@utelle commented on GitHub (Jul 11, 2016):
I will test it within the next few days.
I inspected the code of
tmpfileplus. The approach seems to be more or less the same as what I had implemented in my local version. That is, I think I can forego to publish my own implementation.@utelle commented on GitHub (Jul 11, 2016):
I tested the new implementation. It works as expected.
There is only one thing that I don't like in
tmpfileplus: as default it uses the filename prefixtmp.making the random part of the filename in fact the filename extension. In case the temporary files are not deleted automatically for some reason or need to be inspected during debugging, this makes it difficult to locate the files. I would prefer a default prefixtmp_ortmp-orlibxlsxwriteror no prefix at all. This can easily be achieved by callingtmpfileplusin functionlxw_tmpfilewith a not-NULL prefix parameter likeAlternatively, the default value in
tmpfilepluscould be changed.@jmcnamara commented on GitHub (Jul 11, 2016):
I've left the prefix as it is. If it becomes a real issue for someone I'll change it.
I've merged the tmpfile changes down to master and pushed them in the 0.4.1 release: http://libxlsxwriter.github.io/changes.html
Thanks for the report. Closing.