mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-26 18:21:04 +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
fa8206692b
commit
9ce257fccf
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>
|
2005-10-09 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Headers/Additions/GNUstepBase/GSFileHandle.h:
|
* Headers/Additions/GNUstepBase/GSFileHandle.h:
|
||||||
|
|
|
@ -663,9 +663,42 @@ static NSLock *fileLock = nil;
|
||||||
fileLock = [NSLock new];
|
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
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
RELEASE(_path);
|
RELEASE(_path);
|
||||||
|
RELEASE(_attributes);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -736,7 +769,12 @@ static NSLock *fileLock = nil;
|
||||||
- (NSData*) loadInForeground
|
- (NSData*) loadInForeground
|
||||||
{
|
{
|
||||||
NSData *d = [NSData dataWithContentsOfFile: _path];
|
NSData *d = [NSData dataWithContentsOfFile: _path];
|
||||||
|
NSDictionary *dict;
|
||||||
|
|
||||||
|
dict = [[NSFileManager defaultManager] fileAttributesAtPath: _path
|
||||||
|
traverseLink: YES];
|
||||||
|
RELEASE(_attributes);
|
||||||
|
_attributes = [dict mutableCopy];
|
||||||
[self didLoadBytes: d loadComplete: YES];
|
[self didLoadBytes: d loadComplete: YES];
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue