Packages

J. Landman Gay jacque at hyperactivesw.com
Sun Dec 9 00:23:30 EST 2007


Chipp Walters wrote:
> Good one Sarah, now how to create an
> 
> isBundle() function without the answer file command?

Are you trying to identify any kind of bundle or just a specific type?

You can read the first four characters of the /Contents/Pkginfo file to 
get the specific type; apps are APPL, bundles are BNDL, etc. Just the 
existence of a /Contents/Pkginfo file itself is fairly persuasive for 
identifying a generic bundle or package, and if the contents of the file 
are exactly 8 characters you can be pretty sure you've got yourself a 
bundle.

Off the top of my head, for generic bundles:

function isBundle pPath
   put "/Contents/PkgInfo" after pPath
   return len(url ("file:"&pPath)) = 8
end isBundle

Or for specific ones, like .band files:

function isBundle pPath
   put "/Contents/PkgInfo" after pPath
   return char 1 to 4 of url ("file:"&pPath) = "BNDL"
end isBundle


-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list