/Mac/BuildScript/seticon.m

http://unladen-swallow.googlecode.com/ · Objective C · 26 lines · 19 code · 4 blank · 3 comment · 2 complexity · 356d1dc479ab5b82f0f16f6c357a186a MD5 · raw file

  1. /*
  2. * Simple tool for setting an icon on a file.
  3. */
  4. #import <Cocoa/Cocoa.h>
  5. #include <stdio.h>
  6. int main(int argc, char** argv)
  7. {
  8. if (argc != 3) {
  9. fprintf(stderr, "Usage: seticon ICON TARGET");
  10. return 1;
  11. }
  12. NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
  13. NSString* iconPath = [NSString stringWithUTF8String:argv[1]];
  14. NSString* filePath = [NSString stringWithUTF8String:argv[2]];
  15. [NSApplication sharedApplication];
  16. [[NSWorkspace sharedWorkspace]
  17. setIcon: [[NSImage alloc] initWithContentsOfFile: iconPath]
  18. forFile: filePath
  19. options: 0];
  20. [pool release];
  21. return 0;
  22. }