[futurebasic] Re: [FB] Running app from Download folder

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2017 : Group Archive : Group : All Groups

From: Steve Crossman <steve@...>
Date: Sun, 12 Mar 2017 08:29:13 -0400
Hi Ken,

Thanks for this.   I will be testing this out later today.  

Steve

> On Mar 12, 2017, at 4:37 AM, Ken Shmidheiser <kshmidheiser@...> wrote:
> 
> Simplified version of app in my last post to read application attributes.
> 
> Note that a typical FB executable will return an NSFilePosixPermissions decimal value of 493 (755 in octal or rwxr-xr-x). I'm interested in what value Steve's is returning from the Downloads folder, and if moving it to the Desktop changes the permissions.
> 
> Ken
> 
> 
> output file "Application Attributes"
> 
> include "NSLog.incl"
> 
> local fn BuildMenus
> '~'1
> apple menu @"Application Attributes"
> menu 1, 0, _enable, @"File"
> menu 1, 1, _enable, @"Choose an application to read its attributes.../O"
> edit menu 2
> end fn
> 
> local fn ApplicationAttributes ( fileURL as CFURLRef )
> '~'1
> NSLogClear
> BeginCCode
> NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease];
> NSString *path = [(NSURL *)fileURL path];
> NSString *fileName = [fileManager displayNameAtPath: path];
> NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath: path error: NULL];
> 
> if (fileAttributes != nil)
> {
>    NSLog( @"File attributes for application %@:\n%@.", fileName, fileAttributes);
> }
> else
> {
>    NSLog(@"Path (%@) is invalid.", path);
> }
> EndC
> end fn
> 
> local fn ApplicationPath as CFURLRef
> '~'1
> dim as CFURLRef appURL : appURL = NULL
> 
> BeginCCode
> NSOpenPanel *panel = [NSOpenPanel openPanel];
> NSArray* fileTypes = [NSArray arrayWithObjects:@"app", @"APPL", nil];
> [panel setAllowedFileTypes:fileTypes];
> [panel setFloatingPanel:YES];
> [panel setCanChooseDirectories:NO];
> [panel setCanChooseFiles:YES];
> [panel setAllowsMultipleSelection:NO];
> [panel setTitle:@"Read Application Attributes"];
> [panel setMessage:@"Choose an application to read its attributes"];
> [panel setPrompt:@"Choose application"];
> 
> int result = [panel runModal];
> if (result == NSOKButton)
> {
>   appURL = (CFURLRef)[panel URL];  
> }
> EndC
> end fn = appURL
> 
> local fn CheckAttributes
> '~'1
> dim as CFURLRef appURL
> 
> appURL = fn ApplicationPath
> 
> if ( appURL )
> fn ApplicationAttributes ( appURL )
> else
> // User canceled
> end if 
> end fn 
> 
> local fn DoMenu
> '~'1
> dim as long menuID, itemID
> 
> menuID = menu( _menuID )
> itemID = menu( _itemID )
> 
> select ( menuID )
> case 1
> select (itemID)
> case 1 : fn CheckAttributes
> end select
> end select
> menu
> end fn
> 
> on menu fn DoMenu
> fn BuildMenus
> fn CheckAttributes
> 
> do
> HandleEvents
> until gFBQuit
> 
> 
> 
>