mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Apply fix for bug #26244 by Fred Morcos
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28245 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4f5344d2c2
commit
bd5437b24a
3 changed files with 39 additions and 36 deletions
|
@ -1,3 +1,11 @@
|
|||
2009-04-24 Fred Morcos <fred.morcos"gmail.com>
|
||||
|
||||
* Headers/Foundation/NSFileManager.h:
|
||||
* Source/NSFileManager.m:
|
||||
Fix -fileOwnerAccountID and -fileGroupOwnerAccountID to return the
|
||||
correct type. Also fix return type of HFS methods (though these are
|
||||
Apple filesystem specific and do nothing in GNUstep).
|
||||
|
||||
2009-04-19 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSHashTable.m:
|
||||
|
|
|
@ -190,6 +190,10 @@ extern "C" {
|
|||
@class NSDirectoryEnumerator;
|
||||
@class NSError;
|
||||
|
||||
/* MacOS-X defines OSType as a 32bit unsigned integer.
|
||||
*/
|
||||
typedef uint32_t OSType;
|
||||
|
||||
@interface NSFileManager : NSObject
|
||||
{
|
||||
NSString *_lastError;
|
||||
|
@ -454,15 +458,15 @@ GS_EXPORT NSString* const NSFileSystemFreeNodes;
|
|||
@interface NSDictionary(NSFileAttributes)
|
||||
- (NSDate*) fileCreationDate;
|
||||
- (BOOL) fileExtensionHidden;
|
||||
- (int) fileHFSCreatorCode;
|
||||
- (int) fileHFSTypeCode;
|
||||
- (OSType) fileHFSCreatorCode;
|
||||
- (OSType) fileHFSTypeCode;
|
||||
- (BOOL) fileIsAppendOnly;
|
||||
- (BOOL) fileIsImmutable;
|
||||
- (unsigned long long) fileSize;
|
||||
- (NSString*) fileType;
|
||||
- (unsigned long) fileOwnerAccountID;
|
||||
- (NSNumber*) fileOwnerAccountID;
|
||||
- (NSString*) fileOwnerAccountName;
|
||||
- (unsigned long) fileGroupOwnerAccountID;
|
||||
- (NSNumber*) fileGroupOwnerAccountID;
|
||||
- (NSString*) fileGroupOwnerAccountName;
|
||||
- (NSDate*) fileModificationDate;
|
||||
- (NSUInteger) filePosixPermissions;
|
||||
|
|
|
@ -388,6 +388,7 @@ static NSStringEncoding defaultEncoding;
|
|||
- (BOOL) changeFileAttributes: (NSDictionary*)attributes atPath: (NSString*)path
|
||||
{
|
||||
const _CHAR *lpath = 0;
|
||||
NSNumber *tmpNum;
|
||||
unsigned long num;
|
||||
NSString *str;
|
||||
NSDate *date;
|
||||
|
@ -400,7 +401,8 @@ static NSStringEncoding defaultEncoding;
|
|||
lpath = [defaultManager fileSystemRepresentationWithPath: path];
|
||||
|
||||
#ifndef __MINGW32__
|
||||
num = [attributes fileOwnerAccountID];
|
||||
tmpNum = [attributes fileOwnerAccountID];
|
||||
num = tmpNum ? [tmpNum unsignedLongValue] : NSNotFound;
|
||||
if (num != NSNotFound)
|
||||
{
|
||||
if (chown(lpath, num, -1) != 0)
|
||||
|
@ -455,7 +457,8 @@ static NSStringEncoding defaultEncoding;
|
|||
}
|
||||
}
|
||||
|
||||
num = [attributes fileGroupOwnerAccountID];
|
||||
tmpNum = [attributes fileGroupOwnerAccountID];
|
||||
num = tmpNum ? [tmpNum unsignedLongValue] : NSNotFound;
|
||||
if (num != NSNotFound)
|
||||
{
|
||||
if (chown(lpath, -1, num) != 0)
|
||||
|
@ -769,7 +772,7 @@ static NSStringEncoding defaultEncoding;
|
|||
* If there is no file owner specified, and we are running setuid to
|
||||
* root, then we assume we need to change ownership to correct user.
|
||||
*/
|
||||
if (attributes == nil || ([attributes fileOwnerAccountID] == NSNotFound
|
||||
if (attributes == nil || ([attributes fileOwnerAccountID] == nil
|
||||
&& [attributes fileOwnerAccountName] == nil))
|
||||
{
|
||||
if (geteuid() == 0 && [@"root" isEqualToString: NSUserName()] == NO)
|
||||
|
@ -932,7 +935,7 @@ static NSStringEncoding defaultEncoding;
|
|||
* If there is no file owner specified, and we are running setuid to
|
||||
* root, then we assume we need to change ownership to correct user.
|
||||
*/
|
||||
if (attributes == nil || ([attributes fileOwnerAccountID] == NSNotFound
|
||||
if (attributes == nil || ([attributes fileOwnerAccountID] == nil
|
||||
&& [attributes fileOwnerAccountName] == nil))
|
||||
{
|
||||
if (geteuid() == 0 && [@"root" isEqualToString: NSUserName()] == NO)
|
||||
|
@ -2340,17 +2343,17 @@ static inline void gsedRelease(GSEnumeratedDirectory X)
|
|||
/**
|
||||
* Returns HFS creator attribute (OS X).
|
||||
*/
|
||||
- (int) fileHFSCreatorCode
|
||||
- (OSType) fileHFSCreatorCode
|
||||
{
|
||||
return [[self objectForKey: NSFileHFSCreatorCode] intValue];
|
||||
return [[self objectForKey: NSFileHFSCreatorCode] unsignedLongValue];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HFS type code attribute (OS X).
|
||||
*/
|
||||
- (int) fileHFSTypeCode
|
||||
- (OSType) fileHFSTypeCode
|
||||
{
|
||||
return [[self objectForKey: NSFileHFSTypeCode] intValue];
|
||||
return [[self objectForKey: NSFileHFSTypeCode] unsignedLongValue];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2401,18 +2404,12 @@ static inline void gsedRelease(GSEnumeratedDirectory X)
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the numeric value of the NSFileOwnerAccountID attribute
|
||||
* in the dictionary, or NSNotFound if the attribute is not present.
|
||||
* Return an NSNumber with the numeric value of the NSFileOwnerAccountID attribute
|
||||
* in the dictionary, or nil if the attribute is not present.
|
||||
*/
|
||||
- (unsigned long) fileOwnerAccountID
|
||||
- (NSNumber*) fileOwnerAccountID
|
||||
{
|
||||
NSNumber *n = [self objectForKey: NSFileOwnerAccountID];
|
||||
|
||||
if (n == nil)
|
||||
{
|
||||
return NSNotFound;
|
||||
}
|
||||
return [n unsignedIntValue];
|
||||
return [self objectForKey: NSFileOwnerAccountID];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2424,18 +2421,12 @@ static inline void gsedRelease(GSEnumeratedDirectory X)
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the numeric value of the NSFileGroupOwnerAccountID attribute
|
||||
* in the dictionary, or NSNotFound if the attribute is not present.
|
||||
* Return an NSNumber with the numeric value of the NSFileGroupOwnerAccountID attribute
|
||||
* in the dictionary, or nil if the attribute is not present.
|
||||
*/
|
||||
- (unsigned long) fileGroupOwnerAccountID
|
||||
- (NSNumber*) fileGroupOwnerAccountID
|
||||
{
|
||||
NSNumber *n = [self objectForKey: NSFileGroupOwnerAccountID];
|
||||
|
||||
if (n == nil)
|
||||
{
|
||||
return NSNotFound;
|
||||
}
|
||||
return [n unsignedIntValue];
|
||||
return [self objectForKey: NSFileGroupOwnerAccountID];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3061,12 +3052,12 @@ static NSSet *fileKeys = nil;
|
|||
return group;
|
||||
}
|
||||
|
||||
- (int) fileHFSCreatorCode
|
||||
- (OSType) fileHFSCreatorCode
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (int) fileHFSTypeCode
|
||||
- (OSType) fileHFSTypeCode
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -3281,9 +3272,9 @@ static NSSet *fileKeys = nil;
|
|||
if (key == NSFileGroupOwnerAccountID)
|
||||
return [NSNumber numberWithInt: [self fileGroupOwnerAccountID]];
|
||||
if (key == NSFileHFSCreatorCode)
|
||||
return [NSNumber numberWithInt: [self fileHFSCreatorCode]];
|
||||
return [NSNumber numberWithUnsignedLong: [self fileHFSCreatorCode]];
|
||||
if (key == NSFileHFSTypeCode)
|
||||
return [NSNumber numberWithInt: [self fileHFSTypeCode]];
|
||||
return [NSNumber numberWithUnsignedLong: [self fileHFSTypeCode]];
|
||||
if (key == NSFileImmutable)
|
||||
return [NSNumber numberWithBool: [self fileIsImmutable]];
|
||||
if (key == NSFileModificationDate)
|
||||
|
|
Loading…
Reference in a new issue