Creating temp file in different directory

Started by mwelch, February 11, 2014, 08:53:58 AM

Previous topic - Next topic

mwelch

Hello,

Really enjoying using Exiftool so far. Great work.

I'm looking at using Exiftool inside a Mac app that will be sold through the App Store. As such, the app will be subject to sandboxing restrictions. This presents a problem for Exiftool, as sandboxing prevents the creation of temp files in their normal (parallel to the file under operation) location.

Is there a way to specify in which directory the temp file should be created? I see that other App Store apps use Exiftool, so there's a way around this problem.  I just haven't found it yet!

Thanks.

Phil Harvey

I don't understand.

ExifTool only creates a temporary file when you ask it to write an image.  In this case, it doesn't make sense to prevent it from writing in the image directory because you have asked it to do so.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mwelch

Sorry, I should have been more clear. Mac App Store sandboxing allows you to write only to files that a user specifically enables for you, such as those she chooses in a file open dialog. The app also has access to a temporary directory for scratch files, etc.

In my app, the user chooses a photo, which is then "allowed" in the sandbox. The problem is that exiftool ALSO wants to write a temporary file at the same level of hierarchy as the selected file. This is not allowed in a sandboxed app. (Actually, that's not entirely true. You can set things up such that a file with the same name, but a different extension is allowed to be written.)

So the obvious workaround is to specify where I want exiftool to create the temporary file. (Or to tell exiftool how to name the temporary file.)

Phil Harvey

How odd.

How can you ensure that the temporary file is on the same filesystem as the selected file?  If not, there is no way to guarantee the integrity of the edited file.  If you can't replace it with an atomic rename operation, then the file will be corrupted if the application terminates for any reason during the write.

I find it hard to believe that the requirements for App Store apps can be so restrictive.

But I digress.

The location of the temporary file is not configurable in ExifTool.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).