mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Fix NSData initWithContentsOfURL: caching data of file URLs
This commit is contained in:
parent
48c8a1a6a1
commit
0aaa5307c8
2 changed files with 33 additions and 7 deletions
|
@ -1,3 +1,8 @@
|
|||
2023-07-26 Frederik Seiffert <frederik@algoriddim.com>
|
||||
|
||||
* Source/NSData.m:
|
||||
Fix NSData initWithContentsOfURL: caching data of file URLs.
|
||||
|
||||
2023-07-26 Frederik Seiffert <frederik@algoriddim.com>
|
||||
|
||||
* Source/NSURL.m:
|
||||
|
|
|
@ -643,7 +643,15 @@ failure:
|
|||
{
|
||||
NSData *d;
|
||||
|
||||
d = [url resourceDataUsingCache: YES];
|
||||
if ([url isFileURL])
|
||||
{
|
||||
d = [dataMalloc allocWithZone: NSDefaultMallocZone()];
|
||||
d = AUTORELEASE([d initWithContentsOfFile: [url path]]);
|
||||
}
|
||||
else
|
||||
{
|
||||
d = [url resourceDataUsingCache: YES];
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
|
@ -955,9 +963,15 @@ failure:
|
|||
*/
|
||||
- (id) initWithContentsOfURL: (NSURL*)url
|
||||
{
|
||||
NSData *data = [url resourceDataUsingCache: YES];
|
||||
|
||||
return [self initWithData: data];
|
||||
if ([url isFileURL])
|
||||
{
|
||||
return [self initWithContentsOfFile: [url path]];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSData *data = [url resourceDataUsingCache: YES];
|
||||
return [self initWithData: data];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2359,11 +2373,18 @@ failure:
|
|||
+ (id) dataWithContentsOfURL: (NSURL*)url
|
||||
{
|
||||
NSMutableData *d;
|
||||
NSData *data;
|
||||
|
||||
d = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()];
|
||||
data = [url resourceDataUsingCache: YES];
|
||||
d = [d initWithBytes: [data bytes] length: [data length]];
|
||||
|
||||
if ([url isFileURL])
|
||||
{
|
||||
d = [d initWithContentsOfFile: [url path]];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSData *data = [url resourceDataUsingCache: YES];
|
||||
d = [d initWithBytes: [data bytes] length: [data length]];
|
||||
}
|
||||
return AUTORELEASE(d);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue