Re: FSSpec for non-existant file?
Re: FSSpec for non-existant file?
- Subject: Re: FSSpec for non-existant file?
- From: "Tomas Zahradnicky, Jr." <email@hidden>
- Date: Thu, 15 Nov 2001 16:20:20 +0100
Hello,
I've made enormous use of the two line posix path to FSSpec routine
posted here by Eric and now need to get something similar: an FSSpec
for a non-existant file.
Hi,
the main difference between FSSpec and FSRef is that FSSpec can point
to a nonexistent file, but is not valid across apps. To pass data
between apps use file url. You can simply create unix path to a
folder where should the newly created file be and then use:
err = FSPathMakeRef(const UInt8 * path, FSRef * ref, Boolean * isDirectory)
to create a FSRef to that folder. you should verify that the
isDirectory is true. then use:
err = FSGetCatalogInfo(
const FSRef * ref,
FSCatalogInfoBitmap whichInfo,
FSCatalogInfo * catalogInfo, /* can be NULL */
HFSUniStr255 * outName, /* can be NULL */
FSSpec * fsSpec, /* can be NULL */
FSRef * parentRef); /* can be NULL */
to get a FSSpec for the folder and then finaly:
err = FSMakeFSSpec(fsSpec.vRefNum, fsSpec.parID,
"\p:folder:nonexistentfile",&spec);
you'll get fnfErr, but the fsspec is still valid. make sure you don't
pass this fsspec to other app, because it might not be valid for
other apps... i'm not sure which parID the FSPathMakeRef returns, so
there might be neccessary to either preserve "folder:" in the final
path or not.
-Tomas
--
# Tomas Zahradnicky, Jr
# The Czech Technical University
# FEL-CTU, Prague