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

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

From: Ken Shmidheiser <kshmidheiser@...>
Date: Sun, 12 Mar 2017 04:37:07 -0400
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.


output file "Application Attributes"

include "NSLog.incl"

local fn BuildMenus
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 )
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);
    NSLog(@"Path (%@) is invalid.", path);
end fn

local fn ApplicationPath as CFURLRef
dim as CFURLRef appURL : appURL = NULL

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];  
end fn = appURL

local fn CheckAttributes
dim as CFURLRef appURL

appURL = fn ApplicationPath

if ( appURL )
fn ApplicationAttributes ( appURL )
// User canceled
end if 
end fn 

local fn DoMenu
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
end fn

on menu fn DoMenu
fn BuildMenus
fn CheckAttributes

until gFBQuit