bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

File URLs in NSURL


From: Fred Kiefer
Subject: File URLs in NSURL
Date: Thu, 26 Jun 2003 18:14:28 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204

While playing around with thumbnails (thanks to Charles Philip Chan for the link!) I came up with the following code:

  file = @"~/GNUstep/Images/TextSystem1.png";
  absolute = [file stringByStandardizingPath];
  NSLog(@"file: %@, absolute: %@", file, absolute);
  absolute = [[NSURL fileURLWithPath: absolute] relativeString];
  digest = [[[[absolute dataUsingEncoding: NSASCIIStringEncoding]
                 md5Digest] hexadecimalRepresentation] lowercaseString];

  NSLog(@"file: %@, absolute: %@, digest %@", file, absolute, digest);
  file = [[[@"~" stringByAppendingPathComponent: @".thumbnails"]
              stringByAppendingPathComponent: @"normal"]
             stringByAppendingPathComponent:
                 [digest stringByAppendingPathExtension: @"png"]];

  image = [[NSImage alloc] initByReferencingFile: file];

But this does not give the correct result. According to the specification the URL file name "absolute" should be something like
file:///home/fred/GNUstep/Images/TextSystem1.png

but in GNUStep I do get:
file:/home/fred/GNUstep/Images/TextSystem1.png

When using absoluteString instead of relativeString I get:
file://localhost/home/fred/GNUstep/Images/TextSystem1.png

Again this will result in a different MD5 digest than the one expected by the thumbnail standard, so we wont find the correct file. The question now is, if there is another method to get the required string or if this is a bug in GNUstep, which we should correct.

Cheers
Fred






reply via email to

[Prev in Thread] Current Thread [Next in Thread]