Slench255

File Hider prototype

Aug 13th, 2012
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #import <Foundation/Foundation.h>
  2.  
  3. int main(int argc, char const *argv[])
  4. {
  5.     NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
  6.    
  7.     BOOL option;
  8.     int choice;
  9.     int condition = 0;
  10.    
  11.     do {
  12.         system("clear");
  13.         printf("Show/hide hidden files\n1) Show hidden files.\n2) Hide hidden files.\n0) Exit Progeram");
  14.         printf("\nPlease input your choice: ");
  15.         scanf("%d", &choice);
  16.         // this block seems redundant....
  17.        
  18.         @try{
  19.         if(choice == 1)
  20.             option = YES;
  21.         else if(choice == 2)
  22.             option = NO;
  23.         else if(choice == 0)
  24.             condition = 3;
  25.         else
  26.             condition = 4;
  27.         }
  28.        
  29.         @catch (NSException* e) {
  30.             system("clear");
  31.             printf("INVALID INPUT!");
  32.             condition = 3;
  33.         }
  34.         if(condition < 3) {
  35.             NSString* state = option ? @"YES":@"NO";
  36.             NSString* commandString = [[NSString alloc] initWithFormat: @"defaults write com.apple.Finder AppleShowAllFiles %@", state];
  37.             system([commandString cString]);
  38.             [commandString release];
  39.             [state release];
  40.             system("clear");
  41.             printf("Your files are now ");
  42.             if(option)
  43.                 printf("visible.");
  44.             else
  45.                 printf("hidden");
  46.             printf("\nHold the option/alt key and right click the finder icon, select \"Relaunch\"\n\n");
  47.            
  48.             getchar();
  49.             printf("Would you like to exit?\n1) yes\n2) no\nEnter your input: ");
  50.             int yesNo;
  51.             scanf("%d", &yesNo);
  52.             if(yesNo == 1)
  53.                 condition = 3;
  54.         }
  55.        
  56.     } while(condition < 3);
  57.     [pool drain];
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment