home *** CD-ROM | disk | FTP | other *** search
- /* ---------------------------------------------------------------------------------------------
- Find_icon, code for constructing icon suites for files and folders
-
- by James W. Walker
- preferred e-mail: <mailto:jwwalker@kagi.com>
- alternate e-mail: <mailto:jwwalker@aol.com>, <jim@nisus-soft.com>
- web: <http://users.aol.com/jwwalker/>
-
- File: Get_icon_file_name.c
-
- Copyright ©1997 by James W. Walker
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours.
- If you're going to re-distribute the source, please make it clear
- that the code was descended from James W. Walker's code,
- but that you've made changes.
- ---------------------------------------------------------------------------------------------
- */
-
- #include "Get_icon_file_name.h"
- #include <Folders.h>
- #include <LowMem.h>
- #include <Resources.h>
- #include <TextUtils.h>
-
- /* ------------------------------------------------------------------
- Get_icon_file_name Get the name of the invisible files
- used to store custom icons for folders
- and volumes.
- ------------------------------------------------------------------
- */
- void Get_icon_file_name( Str31 iconFileName )
- {
- short save_resfile, sys_vRefNum, Finder_resfile;
- long sys_dirID;
- Str255 tempName;
-
- tempName[0] = 0;
- save_resfile = CurResFile();
- (void) FindFolder( kOnSystemDisk, kSystemFolderType,
- kDontCreateFolder, &sys_vRefNum, &sys_dirID );
- SetResLoad( false );
- Finder_resfile = HOpenResFile( sys_vRefNum, sys_dirID,
- LMGetFinderName(), fsRdPerm );
- SetResLoad( true );
- if (Finder_resfile != -1) // successful open
- {
- GetIndString( tempName, 11250, 5 );
- CloseResFile( Finder_resfile );
- UseResFile( save_resfile );
- }
-
- if ( (tempName[0] < 32) && (tempName[0] > 0) )
- {
- BlockMoveData( tempName, iconFileName, tempName[0] + 1 );
- }
- else
- {
- BlockMoveData( "\pIcon\r", iconFileName, 6 );
- }
- }
-