ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: mwelch on February 11, 2014, 08:53:58 AM

Title: Creating temp file in different directory
Post by: mwelch on February 11, 2014, 08:53:58 AM
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.
Title: Re: Creating temp file in different directory
Post by: Phil Harvey on February 11, 2014, 01:46:24 PM
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
Title: Re: Creating temp file in different directory
Post by: mwelch on February 11, 2014, 01:50:18 PM
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.)
Title: Re: Creating temp file in different directory
Post by: Phil Harvey on February 11, 2014, 08:10:53 PM
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