Reading remote file attributes
Reading remote file attributes
- Subject: Reading remote file attributes
- From: "Nick Ptacek" <email@hidden>
- Date: Wed, 12 Apr 2006 00:15:03 -0700
I've come across a bit of a problem trying to access the attributes of
a remote file. The file in question is an XML plist, which is
downloaded as an "update" for my program. When the file is
downloaded, using the following code, the file's attributes are not
preserved:
NSURL *myURL = [NSURL URLWithString:@"http://myURL.com/version/Update.plist"];
NSData *urlContents = [myURL resourceDataUsingCache:NO];
if ([urlContents writeToFile:[@"~/Library/Preferences/Update.plist"
stringByExpandingTildeInPath] atomically:YES])
{
NSLog(@"Success!");
}
else
{
NSLog(@"Failure!");
}
The file is written to disk just fine, but with a
creation/modification date set to the current date/time, and not the
original date and time of the file. I know that this could be easily
solved by simply archiving the file on the webserver, and having my
application decompress it, but due to lack of foresight on my part
this isn't the best solution. My application already has a sizeable
userbase, and there will always be people who won't update to the
latest version of the software, so I'm stuck trying to find a
compromise.
I could create a different "update" plist file for newer versions of
the program, but I still need to be able to support older versions of
the program, which would create a bit of a headache. Adding a new
key-value pair to the plist isn't an option due to the way the
structure of the plist is parsed by the older versions of the program.
Is there any way to access the file attributes of the remote plist
file? I could make due with either the creation date or the
modification date, it doesn't really matter. If there's a quick fix
for this it would save me the trouble of maintaining extra files on
the webserver to ensure backwards compatibility.
Thanks for any insight you can bestow!
-Nick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden