[macruby-changes] [4836] MacRuby/trunk/objc.m

source_changes at macosforge.org source_changes at macosforge.org
Wed Oct 27 21:59:48 PDT 2010


Revision: 4836
          http://trac.macosforge.org/projects/ruby/changeset/4836
Author:   lsansonetti at apple.com
Date:     2010-10-27 21:59:44 -0700 (Wed, 27 Oct 2010)
Log Message:
-----------
fix File.expand_path to not resolve symlinks

Modified Paths:
--------------
    MacRuby/trunk/objc.m

Modified: MacRuby/trunk/objc.m
===================================================================
--- MacRuby/trunk/objc.m	2010-10-27 21:36:17 UTC (rev 4835)
+++ MacRuby/trunk/objc.m	2010-10-28 04:59:44 UTC (rev 4836)
@@ -130,22 +130,25 @@
     return rb_str_new2([home_dir fileSystemRepresentation]);
 }
 
-static BOOL
-is_absolute_path(NSString *path, int expand_tilde)
+static bool
+is_absolute_path(NSString *path, bool expand_tilde)
 {
     if (!expand_tilde && [path isAbsolutePath] && [path hasPrefix:@"~"]) {
-	return NO;
+	return false;
     }
     return [path isAbsolutePath];    
 }
 
 static VALUE
-file_expand_path(VALUE fname, VALUE dname, int absolute)
+file_expand_path(VALUE fname, VALUE dname, bool absolute)
 {
     NSString *res = (NSString *)FilePathValue(fname);
 
     if (is_absolute_path(res, !absolute)) {
-	NSString *tmp = [res stringByResolvingSymlinksInPath];
+	// Resolve symlinks only in absolute mode.
+	NSString *tmp = absolute
+	    ? [res stringByResolvingSymlinksInPath]
+	    : [[res stringByExpandingTildeInPath] stringByStandardizingPath];
 	// Make sure we don't have an invalid user path.
 	if ([res hasPrefix:@"~"] && [tmp isEqualToString:res]) {
 	    NSString *user = [[[res pathComponents] objectAtIndex:0]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101027/0e47c401/attachment.html>


More information about the macruby-changes mailing list