Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: f7b280956df077b90c5983eeabc8accdbb0aeb8d authored by Ned Deily on 16 December 2016, 21:40:10 UTC
Version bump for 3.6.0rc2
Tip revision: f7b2809
seticon.m
/*
 * Simple tool for setting an icon on a file.
 */
#import <Cocoa/Cocoa.h>
#include <stdio.h>

int main(int argc, char** argv)
{
	if (argc != 3) {
		fprintf(stderr, "Usage: seticon ICON TARGET");
		return 1;
	}

	NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
	NSString* iconPath = [NSString stringWithUTF8String:argv[1]];
	NSString* filePath = [NSString stringWithUTF8String:argv[2]];

	[NSApplication sharedApplication];

	[[NSWorkspace sharedWorkspace]
		setIcon: [[NSImage alloc] initWithContentsOfFile: iconPath]
		forFile: filePath
		options: 0];
	[pool release];
	return 0;
}
back to top