home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 May / macformat-050.iso / Shareware Plus / Developers / Find_icon folder / Sources / Get_icon_file_name.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-25  |  1.9 KB  |  64 lines  |  [TEXT/CWIE]

  1. /*    ---------------------------------------------------------------------------------------------
  2.     Find_icon, code for constructing icon suites for files and folders
  3.     
  4.     by James W. Walker
  5.     preferred e-mail: <mailto:jwwalker@kagi.com>
  6.     alternate e-mail: <mailto:jwwalker@aol.com>, <jim@nisus-soft.com>
  7.     web: <http://users.aol.com/jwwalker/>
  8.     
  9.     File: Get_icon_file_name.c
  10.     
  11.     Copyright ©1997 by James W. Walker
  12.     
  13.     You may incorporate this sample code into your applications without
  14.     restriction, though the sample code has been provided "AS IS" and the
  15.     responsibility for its operation is 100% yours.
  16.     If you're going to re-distribute the source, please make it clear
  17.     that the code was descended from James W. Walker's code,
  18.     but that you've made changes.
  19.     ---------------------------------------------------------------------------------------------
  20. */
  21.  
  22. #include "Get_icon_file_name.h"
  23. #include <Folders.h>
  24. #include <LowMem.h>
  25. #include <Resources.h>
  26. #include <TextUtils.h>
  27.  
  28. /*    ------------------------------------------------------------------
  29.     Get_icon_file_name            Get the name of the invisible files
  30.                                 used to store custom icons for folders
  31.                                 and volumes.
  32.     ------------------------------------------------------------------
  33. */
  34. void    Get_icon_file_name( Str31 iconFileName )
  35. {
  36.     short    save_resfile, sys_vRefNum, Finder_resfile;
  37.     long    sys_dirID;
  38.     Str255    tempName;
  39.     
  40.     tempName[0] = 0;
  41.     save_resfile = CurResFile();
  42.     (void) FindFolder( kOnSystemDisk, kSystemFolderType,
  43.           kDontCreateFolder, &sys_vRefNum, &sys_dirID );
  44.     SetResLoad( false );
  45.     Finder_resfile = HOpenResFile( sys_vRefNum, sys_dirID,
  46.         LMGetFinderName(), fsRdPerm );
  47.     SetResLoad( true );
  48.     if (Finder_resfile != -1)    // successful open
  49.     {
  50.         GetIndString( tempName, 11250, 5 );
  51.         CloseResFile( Finder_resfile );
  52.         UseResFile( save_resfile );
  53.     }
  54.     
  55.     if ( (tempName[0] < 32) && (tempName[0] > 0) )
  56.     {
  57.         BlockMoveData( tempName, iconFileName, tempName[0] + 1 );
  58.     }
  59.     else
  60.     {
  61.         BlockMoveData( "\pIcon\r", iconFileName, 6 );
  62.     }
  63. }
  64.