Re: Reading remote file attributes
Re: Reading remote file attributes
- Subject: Re: Reading remote file attributes
- From: Sovande Ulv <email@hidden>
- Date: Wed, 12 Apr 2006 10:02:35 +0200
Are you serious?! When you download a file from a http server you
download bytes and when you write those bytes to a new file, the
timestamp of that file is of course set to the time it was created.
If you must change the timestamp of the file you need to set this
yourself when the file is created. RTFM utime(2) and you can get the
timestamp of the original file by examine the 'Last-Modified' HTTP
header in the response.
On 12. apr. 2006, at 09.15, Nick Ptacek wrote:
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!
_______________________________________________
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