mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
Notive when files have changed
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21794 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a097b09d2b
commit
9919e36065
2 changed files with 43 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
2005-10-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSURLHandle.m: alter file handle to nitice if a file has
|
||||
changed.
|
||||
|
||||
2005-10-09 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Additions/GNUstepBase/GSFileHandle.h:
|
||||
|
|
|
@ -663,9 +663,42 @@ static NSLock *fileLock = nil;
|
|||
fileLock = [NSLock new];
|
||||
}
|
||||
|
||||
- (NSData*) availableResourceData
|
||||
{
|
||||
if (_data != nil)
|
||||
{
|
||||
NSDictionary *dict;
|
||||
|
||||
dict = [[NSFileManager defaultManager] fileAttributesAtPath: _path
|
||||
traverseLink: YES];
|
||||
if (dict == nil)
|
||||
{
|
||||
// File no longer exists.
|
||||
DESTROY(_data);
|
||||
DESTROY(_attributes);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDate *original;
|
||||
NSDate *latest;
|
||||
|
||||
original = [_attributes fileModificationDate];
|
||||
latest = [dict fileModificationDate];
|
||||
if ([latest earlierDate: original] != latest)
|
||||
{
|
||||
// File has been modified
|
||||
DESTROY(_data);
|
||||
DESTROY(_attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
return [super availableResourceData];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_path);
|
||||
RELEASE(_attributes);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -736,7 +769,12 @@ static NSLock *fileLock = nil;
|
|||
- (NSData*) loadInForeground
|
||||
{
|
||||
NSData *d = [NSData dataWithContentsOfFile: _path];
|
||||
NSDictionary *dict;
|
||||
|
||||
dict = [[NSFileManager defaultManager] fileAttributesAtPath: _path
|
||||
traverseLink: YES];
|
||||
RELEASE(_attributes);
|
||||
_attributes = [dict mutableCopy];
|
||||
[self didLoadBytes: d loadComplete: YES];
|
||||
return d;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue