<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff></diff>
      <filename>English.lproj/MoveApplication.strings</filename>
    </modified>
    <modified>
      <diff>@@ -24,6 +24,7 @@ static NSString *AlertSuppressKey = @&quot;moveToApplicationsFolderAlertSuppress&quot;;
 
 
 // Helper functions
+static NSString *PreferredInstallLocation(void);
 static BOOL IsInApplicationsFolder(NSString *path);
 static BOOL IsInDownloadsFolder(NSString *path);
 static BOOL Trash(NSString *path);
@@ -51,43 +52,30 @@ void PFMoveToApplicationsFolderIfNecessary()
 		return;
 	}
 
-	// Since we are good to go, get /Applications
-	NSString *applicationsDirectory = [NSSearchPathForDirectoriesInDomains(NSApplicationDirectory, NSLocalDomainMask, YES) lastObject];
-
-	// If the user is not an Administrator, that user will not be able to put the app in /Applications.
-	// So, offer to put in ~/Applications instead if it exists
-	BOOL useUserApplications = applicationsDirectory == nil || ![fm isWritableFileAtPath:applicationsDirectory];
-	BOOL needAuthorization = NO;
-
-	if (useUserApplications) {
-		NSLog(@&quot;Can't write to /Applications, checking ~/Applications&quot;);
-		NSString *userApplicationsDirectory = [NSSearchPathForDirectoriesInDomains(NSApplicationDirectory, NSUserDomainMask, YES) lastObject];
-		NSLog(@&quot;User applicationsDirectory: %@&quot;, userApplicationsDirectory);
-
-		// Require authorization if there's no ~/Applications or if it's not writable
-		if (userApplicationsDirectory == nil || ![fm isWritableFileAtPath:userApplicationsDirectory]) {
-			needAuthorization = YES;
-			useUserApplications = NO;
-		}
-		else {
-			applicationsDirectory = userApplicationsDirectory;
-		}
+	// Since we are good to go, get the preferred installation directory.
+	NSString *applicationsDirectory = PreferredInstallLocation();
+	
+	BOOL useUserApplications = NO;
+	if ([applicationsDirectory hasPrefix:@&quot;~&quot;])
+	{
+		useUserApplications = YES;
+		applicationsDirectory = [applicationsDirectory stringByExpandingTildeInPath];
 	}
-
+	
+	BOOL needAuthorization = ([fm isWritableFileAtPath:applicationsDirectory] == NO);
+	
 	// Setup the alert
 	NSAlert *alert = [[[NSAlert alloc] init] autorelease];
 	{
-		NSString *informativeText = nil;
-
-		if (!useUserApplications) {
-			[alert setMessageText:NSLocalizedStringFromTable(@&quot;Move to Applications folder?&quot;, @&quot;MoveApplication&quot;, nil)];
-			informativeText = NSLocalizedStringFromTable(@&quot;I can move myself to the Applications folder if you'd like.&quot;, @&quot;MoveApplication&quot;, nil);
-		}
-		else {
-			[alert setMessageText:NSLocalizedStringFromTable(@&quot;Move to Applications folder in your Home folder?&quot;, @&quot;MoveApplication&quot;, nil)];
-			informativeText = NSLocalizedStringFromTable(@&quot;You don't have permissions to put me in the main Applications folder, but I can move myself to the Applications folder in your Home folder instead.&quot;, @&quot;MoveApplication&quot;, nil);
+		[alert setMessageText:NSLocalizedStringFromTable(@&quot;Move to Applications folder?&quot;, @&quot;MoveApplication&quot;, nil)];
+		
+		NSString *informativeText = NSLocalizedStringFromTable(@&quot;I can move myself to the Applications folder if you'd like.&quot;, @&quot;MoveApplication&quot;, nil);
+		
+		if (useUserApplications) {
+			informativeText = [informativeText stringByAppendingString:@&quot; &quot;];
+			informativeText = [informativeText stringByAppendingString:NSLocalizedStringFromTable(@&quot;The Applications folder in your Home folder will be used.&quot;, @&quot;MoveApplication&quot;, nil)];
 		}
-
+		
 		if (needAuthorization) {
 			informativeText = [informativeText stringByAppendingString:@&quot; &quot;];
 			informativeText = [informativeText stringByAppendingString:NSLocalizedStringFromTable(@&quot;Note that this will require an administrator password.&quot;, @&quot;MoveApplication&quot;, nil)];
@@ -97,7 +85,7 @@ void PFMoveToApplicationsFolderIfNecessary()
 			informativeText = [informativeText stringByAppendingString:@&quot; &quot;];
 			informativeText = [informativeText stringByAppendingString:NSLocalizedStringFromTable(@&quot;This will keep your Downloads folder uncluttered.&quot;, @&quot;MoveApplication&quot;, nil)];
 		}
-
+		
 		[alert setInformativeText:informativeText];
 
 		// Add buttons
@@ -191,6 +179,20 @@ fail:
 #pragma mark -
 #pragma mark Helper Functions
 
+static NSString *PreferredInstallLocation(void)
+{
+	// Builds an array of possible install locations. This assumes
+	// that if the user has a ~/Applications folder, they'd prefer their
+	// applications to go there.
+	
+	NSMutableArray *paths = [NSMutableArray array];
+	
+	[paths addObjectsFromArray:NSSearchPathForDirectoriesInDomains(NSApplicationDirectory, NSUserDomainMask, NO)];
+	[paths addObjectsFromArray:NSSearchPathForDirectoriesInDomains(NSApplicationDirectory, NSLocalDomainMask, NO)];
+	
+	return [paths objectAtIndex:0];
+}
+
 static BOOL IsInApplicationsFolder(NSString *path)
 {
 	NSEnumerator *e = [NSSearchPathForDirectoriesInDomains(NSApplicationDirectory, NSAllDomainsMask, YES) objectEnumerator];</diff>
      <filename>PFMoveApplication.m</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>99b8b007411f62d95fee3ba429f644d16e9e3f22</id>
    </parent>
  </parents>
  <author>
    <name>Kevin LaCoste</name>
    <email>klacoste@zenvilla.com</email>
  </author>
  <url>http://github.com/potionfactory/LetsMove/commit/f7ce95f08999db510413ddaa76bf3a6c8e34c636</url>
  <id>f7ce95f08999db510413ddaa76bf3a6c8e34c636</id>
  <committed-date>2009-10-07T21:59:10-07:00</committed-date>
  <authored-date>2009-10-07T21:59:10-07:00</authored-date>
  <message>Now prefers installing in the home folder if ~/Applications is present.</message>
  <tree>d4cbe8f6a950ef0212e97dfbf497869be08138e2</tree>
  <committer>
    <name>Kevin LaCoste</name>
    <email>klacoste@zenvilla.com</email>
  </committer>
</commit>
