Saving "Bundle-Type" Documents

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
icouto
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 92
Joined: Wed May 29, 2013 1:54 am
Location: Sydney, Australia

Saving "Bundle-Type" Documents

Post by icouto » Wed May 14, 2014 1:54 am

Is it possible to have my LiveCode (MacOS desktop) app save a document as a 'bundle'?

AFAIK, bundles are just directories, but there must be something special that needs to be done so that the system recognises the directory as a 'bundle file', rather than as a simple directory. Is this something possible to do with LiveCode?

Many thanks in advance for any guidance.

Klaus
Posts: 11576
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Saving "Bundle-Type" Documents

Post by Klaus » Wed May 14, 2014 12:42 pm

Hi Igor,

just add the extension ".bundle" to your folder and that's it!
No idea how to make it work with other suffixes.


Best

Klaus

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 307
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: Saving "Bundle-Type" Documents

Post by jameshale » Thu May 15, 2014 3:21 am

For a full description of the ways of doing this...https://developer.apple.com/library/mac ... -CH106-SW1

James

Simon Knight
Posts: 543
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Saving "Bundle-Type" Documents

Post by Simon Knight » Wed Nov 12, 2014 3:06 pm

Hi,
Like the original poster I want to hide my data files inside a folder that appears to the Mac OS Finder as an application folder. I have managed to get part way :

1) When building the standalone I allowed Livecode (well Revolution!) write the PList file with a name for my application "BankManager", a document type of "bmbm" and an extension of "bmb". Note the extension should be unique and I think it can be more than three characters.

2) Build the application.

3) Open the application package and open the pList file in a text editor.

4) Seek the following portion and add the two new keys and values shown at the end of the snip just before the </dict>:

Code: Select all

<key>CFBundleDocumentTypes</key>
	<array>
		<dict>
			<key>CFBundleTypeExtensions</key>
			<array>
				<string>bmb</string>
			</array>
			<key>CFBundleTypeIconFile</key>
			<string>StandaloneDoc.icns</string>
			
			<key>CFBundleTypeName</key>
				<string>BankManager Files</string>
			<key>CFBundleTypeOSTypes</key>
			<array>
				<string>bmbm</string>
			</array>
			<key>CFBundleTypeRole</key>
			<string>Editor</string>
			<key>NSDocumentClass</key>
			<string>Document</string>
			<key>LSTypeIsPackage</key>
			<true/>
		</dict>
I only managed to get it to work once the NSDocumentClass was added, adding just the LSTypeIsPackage did not work. Next I will try and set some icons.

5) Create a new folder using the Finder or your app and give it the extension you have defined i.e. "bmb" in the example above. You should see the icon change and be given the option to "show package contents" when you right click on the icon.
best wishes
Skids

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7427
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Saving "Bundle-Type" Documents

Post by FourthWorld » Wed Nov 12, 2014 4:37 pm

It may be helpful to keep in mind that stack files can also be used as documents, and being stacks they can contain nearly any data and objects your users may need to store. This would give you tremendous flexibility for a wide range of both disparate media types and rich hierarchical data storage (through custom property sets), and keep your options wide open for consistent deployment to other platforms.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Simon Knight
Posts: 543
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Saving "Bundle-Type" Documents

Post by Simon Knight » Wed Nov 12, 2014 11:25 pm

I would like to try and use a stack as a data stack as you suggest but am uncertain how to proceed. Would a simple design use a standard application stack to hold the program logic and have code that uses the "create stack" command to create a stack file to store data and objects?
best wishes
Skids

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7427
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Saving "Bundle-Type" Documents

Post by FourthWorld » Thu Nov 13, 2014 1:47 am

Simon Knight wrote:Would a simple design use a standard application stack to hold the program logic and have code that uses the "create stack" command to create a stack file to store data and objects?
Yep. When first created, a stack has no file name - much like unsaved documents in any app. You can use the "ask file" command to let the user save it, assigning the path returned from that command to the stack's filename property, and then using the "save" command to write it to disk.

You could conceivably use the same stack for both the user's data and for displaying that data, but I generally try to avoid that. For viewing the data I make a stack in the app named something like "DocTMPL" (easily distinguished in my stack like in the App Browser as the document template), and use the clone command each time I need a copy during the session. But for the data that gets displayed there I often use a plain stack file, named at creation with something arbitrary like UUID, and maintain the relationship between that data stack and the view stack by having a custom prop in the view stack with the name of the stack where its data will be saved.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

alieen
Posts: 1
Joined: Tue Dec 02, 2014 8:07 am

Re: Saving "Bundle-Type" Documents

Post by alieen » Tue Dec 02, 2014 8:15 am

Hi,
Like the original poster I want to hide my data files inside a folder that appears to the Mac OS Finder as an application folder. I have managed to get part way :

1) When building the standalone I allowed Livecode (well Revolution!) write the PList file with a name for my application "BankManager", a document type of "bmbm" and an extension of "bmb". Note the extension should be unique and I think it can be more than three characters.

2) Build the application.
hi

Post Reply

Return to “Mac OS”