mkstemp creates a file. We want a directory
Syntax not supported by Xcode 4.2
Keep compiler happy
Check for nil folder path
correct minor typo