Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import <Foundation/Foundation.h>
- int main(int argc, char const *argv[])
- {
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- BOOL option;
- int choice;
- int condition = 0;
- do {
- system("clear");
- printf("Show/hide hidden files\n1) Show hidden files.\n2) Hide hidden files.\n0) Exit Progeram");
- printf("\nPlease input your choice: ");
- scanf("%d", &choice);
- // this block seems redundant....
- @try{
- if(choice == 1)
- option = YES;
- else if(choice == 2)
- option = NO;
- else if(choice == 0)
- condition = 3;
- else
- condition = 4;
- }
- @catch (NSException* e) {
- system("clear");
- printf("INVALID INPUT!");
- condition = 3;
- }
- if(condition < 3) {
- NSString* state = option ? @"YES":@"NO";
- NSString* commandString = [[NSString alloc] initWithFormat: @"defaults write com.apple.Finder AppleShowAllFiles %@", state];
- system([commandString cString]);
- [commandString release];
- [state release];
- system("clear");
- printf("Your files are now ");
- if(option)
- printf("visible.");
- else
- printf("hidden");
- printf("\nHold the option/alt key and right click the finder icon, select \"Relaunch\"\n\n");
- getchar();
- printf("Would you like to exit?\n1) yes\n2) no\nEnter your input: ");
- int yesNo;
- scanf("%d", &yesNo);
- if(yesNo == 1)
- condition = 3;
- }
- } while(condition < 3);
- [pool drain];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment