[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: Fri, 10 Mar 2017 06:44:44 -0500
Bernie, Brian 

This was exactly what I was doing until it was fixed.    But your code is always so much better…

I mulled the idea of a DMG file too as it MIGHT eliminate the issue.

thanks to you both for your ideas

Any ideas why dragging the app out to Desktop and back to Downloads folder would eliminate it ?

thanks
Steve


> On Mar 10, 2017, at 3:54 AM, Bernie <bernie.fblist@...> wrote:
> 
> 
> Brian wrote:
>> 
>>> Steve Crossman wrote:
>>> 
>>> When the app runs from the Downloads folder in macOS 10.12, it cannot properly locate this folder
>> 
>> Perhaps not as satisfying as fixing the security issue but the app could notify the user ( put up a dialog ) if it finds itself being launched in the Downloads directory ( i.e. ask them to drag the app to the desktop etc. )
>> 
> 
> The following function is based on Brian’s excellent idea. There’s extra code to check if the the app is in a folder (or folders) deeper in the Downloads directory.
> 
> // ---------------
> void local fn AreWeInDownloadsDirectory
> '~'1
> BeginCCode
> NSString *appDirPath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
> NSString *downloadsDirPath = [[[[NSFileManager defaultManager] URLsForDirectory:NSDownloadsDirectory inDomains:NSUserDomainMask] objectAtIndex:0] path];
> NSUInteger length = [downloadsDirPath length];
> if ( length <= [appDirPath length] ) {
>     if ( [downloadsDirPath isEqualToString:[appDirPath substringToIndex:length]] ) {
>          NSAlert *alert = [[NSAlert alloc] init];
>          [alert setMessageText:@"Downloads directory error."];
>          [alert addButtonWithTitle:@"Quit"];
>          [alert setInformativeText:@"Cannot be run from the Downloads directory.\nMove this app to another location and try again."];
>          if ( [alert runModal] == NSAlertFirstButtonReturn ) [NSApp terminate:nil];
>     }
> }
> EndC
> end fn
> 
> fn AreWeInDownloadsDirectory()
> 
> window 1, @"My App"
> print "We got here!"
> 
> RunApplicationEventLoop()
> 
> 
>