Igor Delovski Board Forum Index Igor Delovski Board
My Own Personal Slashdot!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Resources

 
Post new topic   Reply to topic    Igor Delovski Board Forum Index -> Mac Carbon
Mac Carbon  
Author Message
delovski



Joined: 14 Jun 2006
Posts: 3524
Location: Zagreb

PostPosted: Sat Mar 10, 2007 1:49 am    Post subject: Resources Reply with quote

Apple Mailing List: Anybody know of a good resource editor?

"Well, for most of those I would say just use Rez which is available on Mac
OS X. For the icons and such, however, you may be better off just running
ResEdit in Classic."

...
"You say "for OS 8.6 and above," but that's not very specific. Supporting 8.6
or 9 means you'll have to use CarbonLib and the Universal Headers. If
"above" includes Mac OS X, note that Apple stopped updating the Universal
Headers right around the time Mac OS X 10.2 was released. Much of the new
stuff added in Jaguar and anything after Jaguar is not available in the
Universal Headers."

...
"More recent versions of CarbonLib include support for nib files, so you
can use Interface Builder to create interfaces for Carbon applications that
are usable on both Mac OS X and earlier systems."

...
"There really isn't one. Resorcerer is much better than ResEdit, but Doug
McKenna, the author of Resorcerer, abandoned development of the latest
version (2.4) before it was finished and it has several rough edges in the
interface. I use Resorcerer on the rare occasion I need a resource editor,
and it may be your best bet depending on the kind of resources you need to
edit."

...
"I'm currently developping Rezilla, an open source resource editor. It is
under development but three alpha releases have already been around.
The Rezilla project can be found at SourceForge."

...
"Might be worth getting together with the ResKnife folks which is another
open source resource editor."
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3524
Location: Zagreb

PostPosted: Sun May 06, 2007 1:09 am    Post subject: Reply with quote

OpenResFile is not supported in Carbon.

FSpOpenResFile - Resource Manager

"Opens a file’s resource fork using a file system specification (FSSpec) record."

Code:
short FSpOpenResFile (
 const FSSpec *spec,
 SignedByte    permission
);

File Access Permission Constants:

"Specify the type of read and write access to a file or fork."

Code:
enum {
   fsCurPerm = 0x00,
   fsRdPerm = 0x01,
   fsWrPerm = 0x02,
   fsRdWrPerm = 0x03,
   fsRdWrShPerm = 0x04,
   fsRdDenyPerm = 0x10,
   fsWrDenyPerm = 0x20
};


Last edited by delovski on Mon May 07, 2007 2:16 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3524
Location: Zagreb

PostPosted: Sun May 06, 2007 2:54 am    Post subject: Reply with quote

The List: Multiple resource files

"I'm finding that ever since I carbonized my game, and switched from
OpenResFile to FSpOpenResFile, I can't open anything from a resource file
unless I first make that file the current res file by calling UseResFile().
Has anyone else had this problem? Or, has anyone NOT had this problem?"
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3524
Location: Zagreb

PostPosted: Sun May 06, 2007 1:45 pm    Post subject: Reply with quote

The List: FSOpenResFile gives eofErr in Jaguar;

"BTW, in Tiger even "cp" from the command line will copy the resource fork.

FYI, here are some easy ways to examine resource forks from Terminal:
Entire contents:
/Developer/Tools/DeRez /path/to/file
Just the resource types & IDs:
/Developer/Tools/DeRez /path/to/file | grep data
(Those two require the Developer Tools to be installed.)
On an HFS/HFS+ disk, you can refer to the resource fork by adding "/..namedfork/rsrc" to the end of the path:

To see the file size, etc.:
ls -l /path/to/file/..namedfork/rsrc
To see the whole fork in hex:
hexdump -C /path/to/file/..namedfork/rsrc"


Diffrence b/w FSOpenResourceFile() & FSOpenResFile( )

"FSOpenResourceFile allows you to open either fork as a resource fork,
but FsOpenResFile always opens the resource fork, so if your file has its
resource part in its data fork, FsOpenResFile will fail but FSOpenResourceFile
would succeed if you pass parameters telling it to use the data fork."
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3524
Location: Zagreb

PostPosted: Mon May 07, 2007 2:20 pm    Post subject: Reply with quote

FSOpenResFile - Resource Manager

Opens a resource file using a file system reference (FSRef).

Code:
short FSOpenResFile (
 const FSRef *ref,
 SInt8        permission
);


FSOpenResourceFile - Resource Manager

This function allows any named fork of a file to be used for storing
resources. Passing in a null forkname will result in the data fork being
used.


Code:
OSErr FSOpenResourceFile (
 const FSRef   *ref,
 UniCharCount   forkNameLength,
 const UniChar *forkName,
 SInt8          permissions,
 SInt16        *refNum
);
Back to top
View user's profile Send private message Visit poster's website
XNote
Kapetan


Joined: 16 Jun 2006
Posts: 532

PostPosted: Sun Nov 04, 2007 7:51 pm    Post subject: Reply with quote

Mac Mojo: Longest remote home folder test … 600 miles…

"Now in Mac Office 2008, we have done a great deal of modernization across
the board. No longer are we using resource forks and files. We have created
application bundles, library frameworks and are completely Mach-O.

Unfortunately with doing this, the number of files is now upwards of 20,000."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Fri Nov 09, 2007 7:11 pm    Post subject: Reply with quote

CFBundleGetFunctionPointerForName() - CFBundle Reference

"Ownership follows the Get Rule."

Code:
void * CFBundleGetFunctionPointerForName (
   CFBundleRef bundle,
   CFStringRef functionName
);

"CFBundleGetFunctionPointerForName() and related calls automatically load
a bundle if it is not already loaded. When the last reference to the CFBundle
object is released and it is finally deallocated, then the code will be unloaded
if it is still loaded and if the executable is of a type that supports unloading."
Back to top
View user's profile Send private message
XNote
Kapetan


Joined: 16 Jun 2006
Posts: 532

PostPosted: Sat Feb 09, 2008 10:02 pm    Post subject: Reply with quote

The list: IB3: DO NOT USE for Carbon!

"IB 3.0 supports three file formats. The 2.x file format is the same file format
that's been in use in Interface Builder previously. It can be edited by IB 2.0,
and is deployable on earlier versions of Mac OS X. The NIB 3.x file format
supports all the new features, is also deployable on earlier versions of Mac
OS X, but can only be edited with IB 3.0."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3524
Location: Zagreb

PostPosted: Thu Jun 05, 2008 1:22 am    Post subject: Reply with quote

adc - Loading and Unloading Executable Code

"Most applications use only the code from their own main executable file.
However, if you are developing an application that supports plug-ins or
other types of loadable bundles, you need to know how to load the code
from these separate bundles dynamically. Both CFBundle and NSBundle
provide facilities for loading code from a bundle. Depending on your nee-
ds, you may use one or both of these objects in your coding."
Back to top
View user's profile Send private message Visit poster's website
XNote
Kapetan


Joined: 16 Jun 2006
Posts: 532

PostPosted: Thu Jun 05, 2008 4:38 pm    Post subject: Reply with quote

adc - Bundles and the Resource Manager - Bundle Programming Guide

"The automatic loading of resources applies only to the listed files in your
application bundle.

If you load resources from frameworks or other loadable bundles, you must
load those resources manually using the CFBundleOpenBundleResourceMap()
or CFBundleOpenBundleResourceFiles() functions. These functions open the
resource files and return reference numbers that you can pass to Resource
Manager functions."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3524
Location: Zagreb

PostPosted: Fri Jun 20, 2008 10:19 am    Post subject: Reply with quote

theList: Resources in App Bundles. Nearly there

> I'd like to be able to reference files that are also included in the app
> bundle from within my code.


For Carbon:

// soundURL = "file://.../foo.app/Contents/Resources/sound.wav"
CFURLRef soundURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR(sound), CFSTR(wave), NULL);

// soundURL = "file://.../foo.app/Contents/Resources/Sounds/sound.wav"
CFURLRef soundURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR(sound), CFSTR(wave), CFSTR(Sounds));
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3524
Location: Zagreb

PostPosted: Wed Jul 23, 2008 1:22 am    Post subject: Reply with quote

TheList: Location of files on a Mac?

"For plug-ins, quite some techniques exist, todays most typical one is making
them CFBundles with a certain extension that is also defined in your app's
plist.

To see an example of that, open the "Get Info" window of iPhoto and expand
the "Plug-Ins" section. .iPhotoExporter plugins will AFAIK automatically be
added to iPhoto when you double-click them."


See also: TN2015 - Locating Application Support Files under Mac OS X
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Thu Nov 27, 2008 1:32 am    Post subject: Reply with quote

adc - HID Utilities Source

Source code containing CFBundleCreate(), CFBundleLoadExecutable() and
CFBundleGetFunctionPointerForName().
Back to top
View user's profile Send private message
XNote
Kapetan


Joined: 16 Jun 2006
Posts: 532

PostPosted: Mon Dec 01, 2008 4:43 pm    Post subject: Reply with quote

MF - Launch html file from web browser in carbon

"You need to get a CFURL reference to the html file to open, most likely in the
app bundle. So first you get a reference to the main app's bundle, which you
can then use to get the embedded HTML file."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Sat Jun 25, 2011 6:35 pm    Post subject: Reply with quote

MF - Reviving old Mac OS 9 games?

"Rezycle - What it does is reads in the resources inside the file's resource
fork, extracts them, and converts what it can to more modern formats."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Thu Aug 04, 2011 3:14 pm    Post subject: Reply with quote

mactech.com - A Hobbyist's Guide To Programming the Mac OS in C

"Note that AddResource always adds the resource to the resource map in
memory which corresponds to the current resource file. For this reason, you
usually need to set the current resource file to the desired file before calling
AddResource."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Tue Aug 01, 2023 2:58 pm    Post subject: Reply with quote

adc - API Collection: Carbon Core

"In macOS 10.8 and later, most of these APIs are deprecated. For more
information, see Carbon Core Deprecations."



https://github.com/phracker/MacOSX-SDKs/blob/master/MacOSX10.6.sdk/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/Headers/Resources.h

err = FSOpenResourceFile( &ref, 0, NULL, fsRdPerm, res );
if ( noErr == err )
return err;

/* fallback to original resource-fork font */
*res = FSOpenResFile( &ref, fsRdPerm );
err = ResError();
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Sat Aug 19, 2023 8:20 am    Post subject: Reply with quote

juice - AU on XCode 10: ResMerger Error

Fatal Error!
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioUnit.framework/Headers/AudioUnit.r:18:
### Rez - Fatal Error, can't recover.

forums.steinberg.net - Again_au fails to compile

"15 months later I was able to fix the issue by accident. You need to add
some libraries to the project. I think one of them was the accelerate
framework and there was another one. I do not remember exactly which
ones it was, but can take a look."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Sat Aug 19, 2023 2:21 pm    Post subject: Reply with quote

unix.com - resmerger(1) [osx man page]

-srcIs RSRC | DF
The fork in which to look for resources in the input file(s). The default is the data fork (DF).

-dstIs RSRC | DF
The fork in which to write resources in the output file. The default is the data fork (DF).
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Sat Aug 19, 2023 10:11 pm    Post subject: Reply with quote

ChatGPT:

Here's an example of a script that you can use as a Run Script Phase in
Xcode to copy resources from a specific directory to the app bundle during
the build process. This script assumes that your resource files are located in
a directory named "Resources" within your project directory.

In Xcode, select your target.

Go to the "Build Phases" tab.

Click the "+" button and select "New Run Script Phase."

Enter the following script in the script text area:

bash
Code:
# Path to the directory containing your resource files
RESOURCE_DIR="${PROJECT_DIR}/Resources"

# Path to the built app bundle
APP_BUNDLE="${BUILT_PRODUCTS_DIR}/${TARGET_NAME}.app"

# Copy resource files to the app bundle
cp -R "${RESOURCE_DIR}" "${APP_BUNDLE}/Contents/Resources"

This script does the following:

It sets the RESOURCE_DIR variable to the path of your "Resources" directory
within the project.

It sets the APP_BUNDLE variable to the path of the built app bundle.

It uses the cp command to recursively copy the contents of the "Resources"
directory to the "Contents/Resources" directory within the app bundle.

Make sure that the "Resources" directory is located at the root level of your
project directory. Adjust the script and paths as needed based on your
project's structure.

Remember that this script should be added as a Run Script Phase in your
Xcode project's target. After building your application, Xcode will execute
this script as part of the build process, copying the resource files into the
app bundle.
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Sun Aug 20, 2023 2:33 pm    Post subject: Reply with quote

Code:
# Path to the directory containing your resource files
RESOURCE_DIR="${PROJECT_DIR}/Rsrc"

# Path to the built app bundle
APP_BUNDLE="${BUILT_PRODUCTS_DIR}/${TARGET_NAME}.app"

/usr/bin/ResMerger -srcIs RSRC "${RESOURCE_DIR}/Appl_KnjigeNT.rsrc" -o "${APP_BUNDLE}/Contents/Resources/${TARGET_NAME}.rsrc"

cd $BUILT_PRODUCTS_DIR
# rm -f GeneralCocoaProject.zip
rm -f ${TARGET_NAME}.zip
# zip -r GeneralCocoaProject GeneralCocoaProject.app
zip -r ${TARGET_NAME} ${TARGET_NAME}.app
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Igor Delovski Board Forum Index -> Mac Carbon All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Delovski.hr
Powered by php-B.B. © 2001, 2005 php-B.B. Group