Apache OpenOffice (AOO) Bugzilla – Issue 64421
Mac OS X: create temp files in /tmp instead of /var/tmp
Last modified: 2006-05-08 13:39:59 UTC
Facts: Current OOo creates *some* files in /var/tmp and some in /tmp. /tmp is cleaned up on system boot. /var/tmp is not. The variable P_tmpdir is defined in stdio.h as "/var/tmp". Some parts of the code use different strategy to find the directory for temporary files. Apple suggests (http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/Articles/WhereToPutFiles.html#//apple_ref/doc/uid/TP40001411-111010): --- citation --- Mac OS X provides an established set of directories for storing temporary files. The primary directory (/tmp) is where most local files go, but you should never hardcode this path into your application. Using hardcoded paths limits the portability and longevity of your code. Instead, Carbon applications should use the FSFindFolder function (in the Core Services framework) to obtain a reference to the temporary directory; Cocoa applications should use the NSTemporaryDirectory function in Foundation Kit. --- citation --- I experimented a bit with this function and here are the results: # kUserDomain macmini:~/q oo$ gcc -Wall tmpdir.c -framework CoreServices; ./a.out Temp directory is /Volumes/Build/oo/Library/Caches. # kSystemDomain macmini:~/q oo$ gcc -Wall tmpdir.c -framework CoreServices; ./a.out Temp directory is /private/var/tmp/folders.502/TemporaryItems. macmini:~/q oo$ No /tmp ;-) Hmm. So: how "standard" we want to be? Do we want to put temporary directories to system directory or user's temporary directory? Source file for testing: #include <stdio.h> #include <CoreServices/CoreServices.h> int main () { OSStatus status; FSRef tmpDirRef; UInt8 *path; status = FSFindFolder( kSystemDomain, kTemporaryFolderType, kDontCreateFolder, &tmpDirRef); status = FSRefMakePath(&tmpDirRef, path, PATH_MAX); printf("Temp directory is %s.\n", path); return 0; }
I think we should do one of these: 1) Use a proper cocoa function to find the tempfile and use that 2) Use a proper carbon function to find the tempfile and use that 3) Do unix style and just use /tmp. IMHO The documentation does suggest to use /tmp if the "proper" functions are not used.
I forgot to assign to me ;-) mox: we can't do Cocoa and Apple docs explicitly said: "but you should never hardcode this path into your application." ;-) But I prefer /tmp anyway...
Quote: *** The primary directory (/tmp) is where most local files go, but you should never hardcode this path into your application. *** To me the text above means: If you are unable to use the functions we give you (Cocoa/Carbon), you should use /tmp as your temporary files directory.
mox: yes, I understand it. And "we should never hardcode /tmp into our application" ;-)
Created attachment 35737 [details] Does this make at least sv???.tmp directories go into /tmp?
Unfortunately your patch did not make a difference (at least when I patched, compiled and delivered the tools -directory)
mox: yup, it worked here, but it can't work for you, because I forgot to include module sal in the patch but I had it patched in my tree. I'll test the complete patch first in my clean build and then will attach it.
Created attachment 35758 [details] New version
The new version of the patch attached. I verified it works here with m163. Temporary files are created in /tmp: macmini:/tmp oo$ lsof |grep soffice|grep tmp soffice.b 4440 oo 24u unix 0x01b3f1e0 0t0 /tmp/OSL_PIPE_502_SingleOfficeIPC_87c150c14f373b49fa46612c5c9d8c5c soffice.b 4440 oo 36u VREG 14,2 0 9237790 /private/tmp/sv62m.tmp/sv62n.tmp macmini:/tmp oo$ mox: can you please confirm it too?
Pavel: Yes, your patch fixes the issue. Confirmed.
mox: thanks. I'll wait for pj53 integration and will create new cws for this /tmp and /var/tmp stuff once m164 is ready.
Patch applied to pj54. mox: Please verify.
*** Issue 55865 has been marked as a duplicate of this issue. ***
Temporary files are now created in /tmp. Cleaned out /var/tmp to confirm. James
Seen in m167.