O'Reilly logo

Beginning Mac OS® X Programming by Drew McCormack, Michael Trent

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

2.6. Exercises

  1. Use Sampler to watch the Stickies program launch. Let the program sit idle for a few seconds before stopping the sample process. Where did Sampler spend most of its time? If you need some help using the Sampler application, check the documentation under the Help menu.

  2. Use the GetFileInfo and SetFile command-line tools to look-up and change Finder-specific information about files on your disk:

    1. How can you use GetFileInfo to check if a file or folder will be visible in the Finder? Here's a hint: you need to check the file's invisible attribute. Consult the GetFileInfo man page for help.

    2. What arguments would you pass to the SetFile command to make a file or folder invisible? Again, SetFile's man page may help you.

    3. Make a directory named Secrets invisible with the SetFile command. Since you have to use Terminal to run SetFile, you might as well create the Secrets directory in Terminal as well. Use the mkdir command to create Secrets in your home directory.

      Once you've set Secrets' invisible attribute the file should not appear in the Finder. However, you may need to re-launch the Finder to see your change; you can do that using the Force Quit menu item under the Apple menu. You can also use GetFileInfo to verify the invisible attribute is set properly.

      Also you will need to refer to SetFile and GetFileInfo by their full paths in order for your shell to find them. For example /Developer/Tools/SetFile. This is because your command shell doesn't automatically look in /Developer/Tools ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required