![]() |
Resource Fork
I am new on MAC OS 10.4.5 , anyone please tell me that how cud i know that which file have resource fork or which have not. Is ther any special extn for that file.
Thanx in advance Anurag :) |
If you're new to Mac OS X, you really should not concern yourself with resource forks. They are a depricated technology, less and less application crate them (they are mostly from legacy apps/files). Not to mention they are hidden from you on Mac OS X.
Is there some specific reason that you have need of how to find/see resource forks that can help us target how to help you? |
Act, there's one requirement i have to compress whole resource fork , it's first step to get that resource fork and parse it and then get individual resource and compress it by efficient algorithm.
so plese let me know, how can i get resource fork for system's file. |
Earlier we have done same for data fork, but at that i was not involved, that's why i m facing this kind of problem.
|
Well.. first thing I should say is that I don't think there's any reason at all to compress, or even save a resource fork if it existed. Resource forks are ONLY useful to Pre-OS X Mac operating systems, of which there are fewer and fewer around everyday. Non-Mac OSs have no knowledge or care of resource forks. OS X itself (and as far as I know, most OS X applications) has no need of the resource fork. Typically as long as the file has a file extension, OS X can figure out what to do.
You posted: Quote:
And finally.. ls -l file/..namedfork/rsrc I think will list if there is a resource fork or not. Look here for more info on resource forks in OS X (or the lack thereof): http://developer.apple.com/cgi-bin/s...ult_collection |
Note that if you are on Tiger (10.4), you can use 'tar' to create an archive that will preserve all of the data in the file (including resource fork). Then normal Unix methods for compressing that file will work.
|
Act i was in impression that each file have resource fork so why not syatem file... i want resource fork of any file, if system file doesn't have resource then i would like to concern about resource fork of any file such as any application file.
is there any way to create any application file (text, word, image etc) which have resource fork. First i want a file which have resource fork, then i'll write a program to get resource fork by using Resource Manager API's. |
What you are asking about seems similar to this old thread
http://forums.macosxhints.com/showthread.php?t=41293 which might provide useful starting points for whatever you are trying to do. And I'm going to move this to the Developer section since it seems to be about programming. |
> Resource forks are ONLY useful to Pre-OS X Mac operating systems
That is a common misconception. Resource forks are still used by the OS in many places. They are no longer supposed to be used in applications, but they do NOT just belong to legacy files. > First i want a file which have resource fork If you add a custom icon to any file, it will be added to the resource fork. You can add a custom icon to a file in the Finder's Get Info window. You can open the Get Info window by selecting a file and typing <Command>+I or using the "Get Info" selection under the File menu. With the Get Info windows for 2 files open, select and copy an icon from one file, then select the icon in a second file's Get Info window and paste the new icon over the old one. |
thanx triple-A , but i didnt get the way u have told to change icon.
1) i have open get info window for two files, 2) and i have select icon on get info window but therewas no option of copy. how can i copy a icon from get info window..let me know and how can i paste on another get-info window. |
> how can i copy a icon from get info window
"Copy" is an option under the Edit menu. So is Paste. There are also keyboard shortcuts, <Command>+C and <Command>+V repectively. |
thanx triple-A..but how can i see that there is resource fork exist or made by adding icon.:(
|
Quote:
ls -l [file]/..namedfork/rsrc If you want to save yourself the trouble of typing in the whole file path then type ls -l, followed by a Space and drag the file's icon onto the Terminal window. The Terminal should automatically fill-in the file's UNIX path. Then complete the line with /..namedfork/rsrc and type the Return key. |
Hi All
I am using Xcode version 2.2.1 for C Programming on MAC 10.4.5 intel based processor. I want to get resource fork so I am using API's FSpOpenResFile(myFSSpec, fsRdWrPerm), and OSErr FSpOpenRF ( const FSSpec * spec, SInt8 permission, short * refNum ); etc and want to use variable like FSSpec. which library and header file i have to include for using these API's and where is option to include library in Xcode environment. thanx anurags |
Please read XCode documentation.
Documentation wih respect to the Carbon File Manager should be available on your machine here: file:///Developer/ADC%20Reference%20Library/documentation/Carbon/Reference/File_Manager/Reference/reference.html You do not indicate whether you are writing a command line tool (I assume you are) Select a 'New Project' in XCode, and under 'CommandLineTools' select 'CoreServices Tool'. Your project should be set up to use the 'Files.h' interface file as shown in the documentation. |
Act i am creating new project (Commond line Utility->Standard Tool).
And i have included CoreServices.h and Files.h both. 1) What sud i use? I hope Core Services Tool.. m i rt? 2) please let me know the name and path of CarbonLib......is it required to include or not if i ma making project of coreservices type. Anurag |
Quote:
So.. not a misconception at all. Like I said, splitting hairs.. |
Quote:
Nevertheless, they are used in many -- often surprising -- places. Just to keep splitting those hairs finer and finer... I've found resource forks in Applescript scripts and Applets, for example. And as mentioned, they are made for files with custom icons and previews. Carbon Apps. Fonts. Alias files. MS Office documents (no need to lecture about that). In some QuickTime movies and sound files. In Quark and Illustrator files. Probably in a hundred other places that I'm ignorant of. I'm sure that with a modest effort, resource forks could be utterly eliminated from the OS. But the fact remains that they are there in files that many of us use every day and their use in alias files makes them quite important to the OS. BTW: I've encountered an interesting phenomenon while playing at the command-line. ls -l shows alias files as taking up zero bytes. But adding /..namedfork/rsrc shows that the resource fork does take up a few bytes. Do you know of any way to use the Terminal to list the size of the combined forks for a given file? |
Two fairly common resource-forked items are
.textClipping and .webloc files (produced via drag-n-drop into Finder). |
Quote:
Quote:
Unix commands in general only deal with the datafork. Hence 'ls' knows nothing of the resource fork when you give it the name of the file. You need to tell it to look at the resource fork by means of that magic incantation. Quote:
|
Quote:
Quote:
I think that's a disingenuous argument. At what point do you distinguish the "Finder" from the "OS" ...? Similarly, one might suggest that UNIX could exist without /bin, but then it wouldn't be the same OS. |
Quote:
|
Hi Triple-A
I had tried ls -ls - file/..namedfork/rsrc . 1) first i changed icon of a abc.cpp file. According to u, this file have resource fork. 2) And i run command ls -l abc.cpp/..namedfork/rsrc and i got the result rw-r-r-- 1 punitsin punitsin 46901 Jun 5 14:27 abc.cpp/..namedfork/rsrc is it desired answer?? if yes then wht's 46901, plz tell me. Act therare one more file xyz.rtf , i didnt changed icon for this file and fire same command for it. and i got the same result but i little bit diffrence. rw-r-r-- 1 punitsin punitsin 0 Jun 5 4:27 xyz.rtf/..namedfork/rsrc plzz tell me how can i know that abc.cpp have resource fork. thanx in advance anurags thanx anurag |
Excuse me for butting in as an absolute non-expert, but I seem to have missed something here. Resource forks are only ever used now to hold things that could just as well have been in a resource folder of a bundle. Shouldn't the OP just be creating a bundle for his app?
|
Quote:
By the way, please avoid using abbreviations like "wht" & "plz". This is not a chat room and there is no reason to save keystrokes. Precision of communication is much more important. Quote:
|
Quote:
|
Hi Hayne
Quote:
You are right that i am writing an utility which will deal with resource fork of existing file. anurags |
Format Of Resource Fork
Hi All
finally i got the resource fork from a file, i have checked it, it's seems good. Actually i have read documentation about resource fork that i got from apple's site. http://developer.apple.com/documenta...ml#HEADING99-0 But there are some problem in my resource fork. The offset in resource map table is false for resoutce type list and reference list. Act i have one resource mean...there is one type and one resource id. So offset for resource typelist would be 1e(30) but the entry in the resource fork is 1c(28). Smilary for offset of reference list, entry in the typelist is 0a but it should be 8. I am not getting what happend act. if any know abt it, pease let me know...Actually what's happend with my resource fork. Anurags |
Relatively few Mac developers nowadays deal with resource forks.
In particular, I have no experience programming the contents of a resource fork. It is therefore unlikely you will get the help you need on these forums. You'd do better on a more specialized mailing list - e.g. the Carbon mailing list (see lists.apple.com) |
Hi All
By adding custom icon we can add resource fork in any file,but i have a requirement that any file which have atleast two resource fork. So please tell me , one another way through which i can add one more resource in resource fork. I am also trying with carbon API, but each n every time AddResource API is failed. #include <stdio.h> #include <Files.h> // Open resource fork and add a resource in the fork int main (int argc, const char * argv[]) { // insert code here... FILE *fPtr = NULL ; size_t byteWritten = 0 ; UInt8 *filePath = (UInt8 *) "/Users/punitsindhwani/Documents/rsrc_fork/Testing/mac_rsrc_fork/rsrc.rtf" ; SInt16 forkRefNum = 0 ; SInt64 forkSize = 0 ; ByteCount actualCount = 0 ; //SInt16 fileRefNum = 0 ; void *buffer = NULL ; OSErr err ; FSRef fsref ; Boolean isDirectory = false ; HFSUniStr255 resourceForkName; UniCharCount forkNameLength; UniChar *forkName; ResType resourceType; short resourceID; char *rData = "Anurag" ; // make FSRef from path err = FSPathMakeRef(filePath, &fsref, &isDirectory) ; if((err != noErr) && (isDirectory)) { printf("\nFSPathMakeRef() Functin failed.\n"); return 1; } // Get Resource Fork name err = FSGetResourceForkName(&resourceForkName); if(err != noErr) { printf("\nFSGetResourceForkName() Functin failed.\n"); return 1; } forkNameLength = resourceForkName.length ; forkName = resourceForkName.unicode ; // Open Resource Fork /* err = FSOpenFork(&fsref,forkNameLength,forkName,fsRdWrPerm, &forkRefNum); if(err != noErr) { printf("\nFSOpenFork() Function failed.\n"); return 1; } */ // change resource fork err = FSOpenResourceFile(&fsref,forkNameLength,forkName,fsRdWrPerm, &forkRefNum); if(err != noErr) { printf("\nFSOpenResFile() Functin failed.\n Error No -> %d\n",err); return 1; } UseResFile(forkRefNum); err = ResError(); if(err != noErr) { printf("\nUseResFile() Functin failed.\nError No -> %d\n",err); return 1; } // Add resource resourceType = 'STR' ; resourceID = 128 ; AddResource(rData,resourceType,resourceID,""); err = ResError(); if(err != noErr) { printf("\nAddResource() Functin failed.\nError No -> %d\n",err); return 1; } UpdateResFile(forkRefNum); err = ResError(); if(err != noErr) { printf("\nUpdateResFile() Functin failed.\n Error No -> %d\n",err); return 1; } // Get size of the open fork err = FSGetForkSize(forkRefNum, &forkSize); if(err != noErr) { printf("\nFSGetForkSize() Functin failed.\n"); return 1; } // Assign memory to buffer buffer = malloc(forkSize); memset(buffer, '0', forkSize); // Read Resource fork err = FSReadFork(forkRefNum, fsFromStart, 0, forkSize, buffer, &actualCount); if(err != noErr) { printf("\nFSReadFork() Functin failed.\n"); return 1; } // Open a file and Write buffer in the file. fPtr = fopen("rsrc_fork.frk","wb+"); if(fPtr == NULL) { printf("\nfopen() Functin failed.\n"); return 1; } byteWritten = fwrite(buffer, 1, forkSize, fPtr); if(byteWritten != forkSize) { printf("\nfwrite() Functin failed.\n"); return 1; } // close file err = fclose(fPtr); if(err != noErr) { printf("\nfclose Functin failed.\n"); return 1; } // To Close Resource fork err = FSCloseFork(forkRefNum); if(err != noErr) { printf("\nFSCloseFork Functin failed.\n"); return 1; } return 0; } Each and every time AddResource() failed and err no is -111. please let me know wht's is wrong here. Thanks In Advance Anurag |
Quote:
resourceType = 'STR ' ; |
| All times are GMT -5. The time now is 06:19 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.