Fix various Xcode analyzer warnings.

Most were pretty harmless, and were addressed by renaming functions to match the Core
Foundation naming conventions, but there was one actual memory leak, and some potential
uses of uninitialised data.
Add missing 'period' to files launched via 'Open In' before file extension.

Fixes bug #694711. As far as I could see, opening an XPS worked fine, the
first time. However, if the same file was opened a second time, then it
should have been saved with a number, e.g. foo(1).xps. However, the period
was ommitted, so the file wasn't recognised as an XPS.

This presumably wasn't an issue for PDF files, as PDF format is assumed
by default (I am guessing).
Fix deleting wrong file or crashing app if first file deleted.

Correct an off-by-one error in the file deletion code.