Moved some constants.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14442 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2002-09-15 08:55:29 +00:00
parent 60064aef0d
commit c2ace95989
4 changed files with 162 additions and 245 deletions

View file

@ -1,7 +1,7 @@
2002-09-15 Richard Frith-Macdonald <rfm@gnu.org> 2002-09-15 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSFileManager.m: MacOS-X ([componentsToDisplayForPath:]) and * Source/NSFileManager.m: MacOS-X ([componentsToDisplayForPath:]) and
([displayNameAtPath:]) methods imnplemented. ([displayNameAtPath:]) methods implemented. Creation date added.
2002-09-13 Adam Fedor <fedor@gnu.org> 2002-09-13 Adam Fedor <fedor@gnu.org>

View file

@ -130,11 +130,14 @@
@end /* NSDirectoryEnumerator */ @end /* NSDirectoryEnumerator */
/* File Attributes */ /* File Attributes */
GS_EXPORT NSString* const NSFileCreationDate;
GS_EXPORT NSString* const NSFileDeviceIdentifier; GS_EXPORT NSString* const NSFileDeviceIdentifier;
GS_EXPORT NSString* const NSFileGroupOwnerAccountName; GS_EXPORT NSString* const NSFileGroupOwnerAccountName;
GS_EXPORT NSString* const NSFileGroupOwnerAccountNumber;
GS_EXPORT NSString* const NSFileDeviceIdentifier; GS_EXPORT NSString* const NSFileDeviceIdentifier;
GS_EXPORT NSString* const NSFileModificationDate; GS_EXPORT NSString* const NSFileModificationDate;
GS_EXPORT NSString* const NSFileOwnerAccountName; GS_EXPORT NSString* const NSFileOwnerAccountName;
GS_EXPORT NSString* const NSFileOwnerAccountNumber;
GS_EXPORT NSString* const NSFilePosixPermissions; GS_EXPORT NSString* const NSFilePosixPermissions;
GS_EXPORT NSString* const NSFileReferenceCount; GS_EXPORT NSString* const NSFileReferenceCount;
GS_EXPORT NSString* const NSFileSize; GS_EXPORT NSString* const NSFileSize;
@ -142,11 +145,6 @@ GS_EXPORT NSString* const NSFileSystemFileNumber;
GS_EXPORT NSString* const NSFileSystemNumber; GS_EXPORT NSString* const NSFileSystemNumber;
GS_EXPORT NSString* const NSFileType; GS_EXPORT NSString* const NSFileType;
#ifndef STRICT_MACOS_X
GS_EXPORT NSString* const NSFileGroupOwnerAccountNumber;
GS_EXPORT NSString* const NSFileOwnerAccountNumber;
#endif
/* File Types */ /* File Types */
GS_EXPORT NSString* const NSFileTypeDirectory; GS_EXPORT NSString* const NSFileTypeDirectory;

View file

@ -2231,9 +2231,10 @@ static int sparc_warn = 0;
const char* cpath = [self fileSystemRepresentationWithPath: path]; const char* cpath = [self fileSystemRepresentationWithPath: path];
int mode; int mode;
int count; int count;
id values[12]; id values[13];
id keys[12] = { id keys[13] = {
NSFileSize, NSFileSize,
NSFileCreationDate,
NSFileModificationDate, NSFileModificationDate,
NSFileReferenceCount, NSFileReferenceCount,
NSFileSystemNumber, NSFileSystemNumber,
@ -2272,168 +2273,167 @@ static int sparc_warn = 0;
#endif /* (__MINGW__) */ #endif /* (__MINGW__) */
values[0] = [NSNumber numberWithUnsignedLongLong: statbuf.st_size]; values[0] = [NSNumber numberWithUnsignedLongLong: statbuf.st_size];
values[1] = [NSDate dateWithTimeIntervalSince1970: statbuf.st_mtime]; values[1] = [NSDate dateWithTimeIntervalSince1970: statbuf.st_ctime];
values[2] = [NSNumber numberWithUnsignedInt: statbuf.st_nlink]; values[2] = [NSDate dateWithTimeIntervalSince1970: statbuf.st_mtime];
values[3] = [NSNumber numberWithUnsignedLong: statbuf.st_dev]; values[3] = [NSNumber numberWithUnsignedInt: statbuf.st_nlink];
values[4] = [NSNumber numberWithUnsignedLong: statbuf.st_ino]; values[4] = [NSNumber numberWithUnsignedLong: statbuf.st_dev];
values[5] = [NSNumber numberWithUnsignedInt: statbuf.st_dev]; values[5] = [NSNumber numberWithUnsignedLong: statbuf.st_ino];
values[6] = [NSNumber numberWithUnsignedInt: statbuf.st_mode]; values[6] = [NSNumber numberWithUnsignedInt: statbuf.st_dev];
values[7] = [NSNumber numberWithUnsignedInt: statbuf.st_mode];
mode = statbuf.st_mode & S_IFMT; mode = statbuf.st_mode & S_IFMT;
if (mode == S_IFREG) if (mode == S_IFREG)
values[7] = NSFileTypeRegular; values[8] = NSFileTypeRegular;
else if (mode == S_IFDIR) else if (mode == S_IFDIR)
values[7] = NSFileTypeDirectory; values[8] = NSFileTypeDirectory;
else if (mode == S_IFCHR) else if (mode == S_IFCHR)
values[7] = NSFileTypeCharacterSpecial; values[8] = NSFileTypeCharacterSpecial;
else if (mode == S_IFBLK) else if (mode == S_IFBLK)
values[7] = NSFileTypeBlockSpecial; values[8] = NSFileTypeBlockSpecial;
#ifdef S_IFLNK #ifdef S_IFLNK
else if (mode == S_IFLNK) else if (mode == S_IFLNK)
values[7] = NSFileTypeSymbolicLink; values[8] = NSFileTypeSymbolicLink;
#endif #endif
else if (mode == S_IFIFO) else if (mode == S_IFIFO)
values[7] = NSFileTypeFifo; values[8] = NSFileTypeFifo;
#ifdef S_IFSOCK #ifdef S_IFSOCK
else if (mode == S_IFSOCK) else if (mode == S_IFSOCK)
values[7] = NSFileTypeSocket; values[8] = NSFileTypeSocket;
#endif #endif
else else
values[7] = NSFileTypeUnknown; values[8] = NSFileTypeUnknown;
if (copy == NO) if (copy == NO)
{ {
#ifdef __MINGW_NOT_AVAILABLE_YET #ifdef __MINGW_NOT_AVAILABLE_YET
{
DWORD dwRtnCode = 0;
PSID pSidOwner;
BOOL bRtnBool = TRUE;
LPTSTR AcctName, DomainName;
DWORD dwAcctName = 1, dwDomainName = 1;
SID_NAME_USE eUse = SidTypeUnknown;
HANDLE hFile;
PSECURITY_DESCRIPTOR pSD;
{ // Get the handle of the file object.
DWORD dwRtnCode = 0; hFile = CreateFile(
PSID pSidOwner; "myfile.txt",
BOOL bRtnBool = TRUE; GENERIC_READ,
LPTSTR AcctName, DomainName; FILE_SHARE_READ,
DWORD dwAcctName = 1, dwDomainName = 1; NULL,
SID_NAME_USE eUse = SidTypeUnknown; OPEN_EXISTING,
HANDLE hFile; FILE_ATTRIBUTE_NORMAL,
PSECURITY_DESCRIPTOR pSD; NULL);
// Get the handle of the file object. // Check GetLastError for CreateFile error code.
hFile = CreateFile( if (hFile == INVALID_HANDLE_VALUE) {
"myfile.txt", DWORD dwErrorCode = 0;
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
// Check GetLastError for CreateFile error code. dwErrorCode = GetLastError();
if (hFile == INVALID_HANDLE_VALUE) { _tprintf(TEXT("CreateFile error = %d\n"), dwErrorCode);
DWORD dwErrorCode = 0; return -1;
}
dwErrorCode = GetLastError(); // Allocate memory for the SID structure.
_tprintf(TEXT("CreateFile error = %d\n"), dwErrorCode); pSidOwner = (PSID)GlobalAlloc(
return -1; GMEM_FIXED,
} sizeof(PSID));
// Allocate memory for the SID structure. // Allocate memory for the security descriptor structure.
pSidOwner = (PSID)GlobalAlloc( pSD = (PSECURITY_DESCRIPTOR)GlobalAlloc(
GMEM_FIXED, GMEM_FIXED,
sizeof(PSID)); sizeof(PSECURITY_DESCRIPTOR));
// Allocate memory for the security descriptor structure. // Get the owner SID of the file.
pSD = (PSECURITY_DESCRIPTOR)GlobalAlloc( dwRtnCode = GetSecurityInfo(
GMEM_FIXED, hFile,
sizeof(PSECURITY_DESCRIPTOR)); SE_FILE_OBJECT,
OWNER_SECURITY_INFORMATION,
&pSidOwner,
NULL,
NULL,
NULL,
&pSD);
// Get the owner SID of the file. // Check GetLastError for GetSecurityInfo error condition.
dwRtnCode = GetSecurityInfo( if (dwRtnCode != ERROR_SUCCESS) {
hFile, DWORD dwErrorCode = 0;
SE_FILE_OBJECT,
OWNER_SECURITY_INFORMATION,
&pSidOwner,
NULL,
NULL,
NULL,
&pSD);
// Check GetLastError for GetSecurityInfo error condition. dwErrorCode = GetLastError();
if (dwRtnCode != ERROR_SUCCESS) { _tprintf(TEXT("GetSecurityInfo error = %d\n"), dwErrorCode);
DWORD dwErrorCode = 0; return -1;
}
dwErrorCode = GetLastError(); // First call to LookupAccountSid to get the buffer sizes.
_tprintf(TEXT("GetSecurityInfo error = %d\n"), dwErrorCode); bRtnBool = LookupAccountSid(
return -1; NULL, // local computer
} pSidOwner,
AcctName,
(LPDWORD)&dwAcctName,
DomainName,
(LPDWORD)&dwDomainName,
&eUse);
// First call to LookupAccountSid to get the buffer sizes. // Reallocate memory for the buffers.
bRtnBool = LookupAccountSid( AcctName = (char *)GlobalAlloc(
NULL, // local computer GMEM_FIXED,
pSidOwner, dwAcctName);
AcctName,
(LPDWORD)&dwAcctName,
DomainName,
(LPDWORD)&dwDomainName,
&eUse);
// Reallocate memory for the buffers. // Check GetLastError for GlobalAlloc error condition.
AcctName = (char *)GlobalAlloc( if (AcctName == NULL) {
GMEM_FIXED, DWORD dwErrorCode = 0;
dwAcctName);
// Check GetLastError for GlobalAlloc error condition. dwErrorCode = GetLastError();
if (AcctName == NULL) { _tprintf(TEXT("GlobalAlloc error = %d\n"), dwErrorCode);
DWORD dwErrorCode = 0; return -1;
}
dwErrorCode = GetLastError(); DomainName = (char *)GlobalAlloc(
_tprintf(TEXT("GlobalAlloc error = %d\n"), dwErrorCode); GMEM_FIXED,
return -1; dwDomainName);
}
DomainName = (char *)GlobalAlloc( // Check GetLastError for GlobalAlloc error condition.
GMEM_FIXED, if (DomainName == NULL) {
dwDomainName); DWORD dwErrorCode = 0;
// Check GetLastError for GlobalAlloc error condition. dwErrorCode = GetLastError();
if (DomainName == NULL) { _tprintf(TEXT("GlobalAlloc error = %d\n"), dwErrorCode);
DWORD dwErrorCode = 0; return -1;
dwErrorCode = GetLastError(); }
_tprintf(TEXT("GlobalAlloc error = %d\n"), dwErrorCode);
return -1;
} // Second call to LookupAccountSid to get the account name.
bRtnBool = LookupAccountSid(
NULL, // name of local or remote computer
pSidOwner, // security identifier
AcctName, // account name buffer
(LPDWORD)&dwAcctName, // size of account name buffer
DomainName, // domain name
(LPDWORD)&dwDomainName, // size of domain name buffer
&eUse); // SID type
// Second call to LookupAccountSid to get the account name. // Check GetLastError for LookupAccountSid error condition.
bRtnBool = LookupAccountSid( if (bRtnBool == FALSE) {
NULL, // name of local or remote computer DWORD dwErrorCode = 0;
pSidOwner, // security identifier
AcctName, // account name buffer
(LPDWORD)&dwAcctName, // size of account name buffer
DomainName, // domain name
(LPDWORD)&dwDomainName, // size of domain name buffer
&eUse); // SID type
// Check GetLastError for LookupAccountSid error condition. dwErrorCode = GetLastError();
if (bRtnBool == FALSE) {
DWORD dwErrorCode = 0;
dwErrorCode = GetLastError(); if (dwErrorCode == ERROR_NONE_MAPPED)
_tprintf(TEXT("Account owner not found for specified SID.\n"));
else
_tprintf(TEXT("Error in LookupAccountSid.\n"));
return -1;
if (dwErrorCode == ERROR_NONE_MAPPED) } else if (bRtnBool == TRUE)
_tprintf(TEXT("Account owner not found for specified SID.\n"));
else
_tprintf(TEXT("Error in LookupAccountSid.\n"));
return -1;
} else if (bRtnBool == TRUE) // Print the account name.
_tprintf(TEXT("Account owner = %s\n"), AcctName);
// Print the account name.
_tprintf(TEXT("Account owner = %s\n"), AcctName);
return 0;
}
return 0;
}
#endif #endif
@ -2445,15 +2445,15 @@ if (AcctName == NULL) {
if (pw) if (pw)
{ {
values[8] = [NSString stringWithCString: pw->pw_name]; values[9] = [NSString stringWithCString: pw->pw_name];
} }
else else
{ {
values[8] = @"UnknownUser"; values[9] = @"UnknownUser";
} }
} }
#else #else
values[8] = @"UnknownUser"; values[9] = @"UnknownUser";
#endif /* HAVE_PWD_H */ #endif /* HAVE_PWD_H */
#if defined(HAVE_GRP_H) && !(defined(sparc) && defined(DEBUG)) #if defined(HAVE_GRP_H) && !(defined(sparc) && defined(DEBUG))
@ -2470,11 +2470,11 @@ if (AcctName == NULL) {
} }
if (gp) if (gp)
{ {
values[9] = [NSString stringWithCString: gp->gr_name]; values[10] = [NSString stringWithCString: gp->gr_name];
} }
else else
{ {
values[9] = @"UnknownGroup"; values[10] = @"UnknownGroup";
} }
endgrent(); endgrent();
} }
@ -2487,17 +2487,17 @@ if (AcctName == NULL) {
fprintf(stderr, "WARNING (NSFileManager): Disabling group enums (setgrent, etc) since this crashes gdb on sparc machines\n"); fprintf(stderr, "WARNING (NSFileManager): Disabling group enums (setgrent, etc) since this crashes gdb on sparc machines\n");
} }
#endif #endif
values[9] = @"UnknownGroup"; values[10] = @"UnknownGroup";
#endif #endif
values[10] = [NSNumber numberWithUnsignedInt: statbuf.st_uid]; values[11] = [NSNumber numberWithUnsignedInt: statbuf.st_uid];
values[11] = [NSNumber numberWithUnsignedInt: statbuf.st_gid]; values[12] = [NSNumber numberWithUnsignedInt: statbuf.st_gid];
count = 12; count = 13;
} }
else else
{ {
NSString *u = NSUserName(); NSString *u = NSUserName();
count = 8; /* No ownership details needed. */ count = 9; /* No ownership details needed. */
/* /*
* If we are running setuid to root - we need to specify the user * If we are running setuid to root - we need to specify the user
* to be the owner of copied files. * to be the owner of copied files.
@ -2516,3 +2516,30 @@ if (AcctName == NULL) {
} }
@end /* NSFileManager (PrivateMethods) */ @end /* NSFileManager (PrivateMethods) */
NSString * const NSFileCreationDate = @"NSFileCreationDate";
NSString * const NSFileDeviceIdentifier = @"NSFileDeviceIdentifier";
NSString * const NSFileGroupOwnerAccountName = @"NSFileGroupOwnerAccountName";
NSString * const NSFileGroupOwnerAccountNumber = @"NSFileGroupOwnerAccountNumber";
NSString * const NSFileModificationDate = @"NSFileModificationDate";
NSString * const NSFileOwnerAccountName = @"NSFileOwnerAccountName";
NSString * const NSFileOwnerAccountNumber = @"NSFileOwnerAccountNumber";
NSString * const NSFilePosixPermissions = @"NSFilePosixPermissions";
NSString * const NSFileReferenceCount = @"NSFileReferenceCount";
NSString * const NSFileSize = @"NSFileSize";
NSString * const NSFileSystemFileNumber = @"NSFileSystemFileNumber";
NSString * const NSFileSystemFreeNodes = @"NSFileSystemFreeNodes";
NSString * const NSFileSystemFreeSize = @"NSFileSystemFreeSize";
NSString * const NSFileSystemNodes = @"NSFileSystemNodes";
NSString * const NSFileSystemNumber = @"NSFileSystemNumber";
NSString * const NSFileSystemSize = @"NSFileSystemSize";
NSString * const NSFileType = @"NSFileType";
NSString * const NSFileTypeBlockSpecial = @"NSFileTypeBlockSpecial";
NSString * const NSFileTypeCharacterSpecial = @"NSFileTypeCharacterSpecial";
NSString * const NSFileTypeDirectory = @"NSFileTypeDirectory";
NSString * const NSFileTypeFifo = @"NSFileTypeFifo";
NSString * const NSFileTypeRegular = @"NSFileTypeRegular";
NSString * const NSFileTypeSocket = @"NSFileTypeSocket";
NSString * const NSFileTypeSymbolicLink = @"NSFileTypeSymbolicLink";
NSString * const NSFileTypeUnknown = @"NSFileTypeUnknown";

View file

@ -89,66 +89,6 @@ NSString *NSLoadedClasses;
NSString *StreamException; NSString *StreamException;
/*
* File attributes names
*/
/* File Attributes */
NSString *NSFileDeviceIdentifier;
NSString *NSFileGroupOwnerAccountName;
NSString *NSFileGroupOwnerAccountNumber;
NSString *NSFileModificationDate;
NSString *NSFileOwnerAccountName;
NSString *NSFileOwnerAccountNumber;
NSString *NSFilePosixPermissions;
NSString *NSFileReferenceCount;
NSString *NSFileSize;
NSString *NSFileSystemFileNumber;
NSString *NSFileSystemNumber;
NSString *NSFileType;
/* File Types */
NSString *NSFileTypeDirectory;
NSString *NSFileTypeRegular;
NSString *NSFileTypeSymbolicLink;
NSString *NSFileTypeSocket;
NSString *NSFileTypeFifo;
NSString *NSFileTypeCharacterSpecial;
NSString *NSFileTypeBlockSpecial;
NSString *NSFileTypeUnknown;
/* FileSystem Attributes */
NSString *NSFileSystemSize;
NSString *NSFileSystemFreeSize;
NSString *NSFileSystemNodes;
NSString *NSFileSystemFreeNodes;
/* Standard domains */ /* Standard domains */
NSString *NSArgumentDomain; NSString *NSArgumentDomain;
@ -319,54 +259,6 @@ GSBuildStrings()
= [[SClass alloc] initWithCString: "NSDecimalSeparator"]; = [[SClass alloc] initWithCString: "NSDecimalSeparator"];
NSEarlierTimeDesignations NSEarlierTimeDesignations
= [[SClass alloc] initWithCString: "NSEarlierTimeDesignations"]; = [[SClass alloc] initWithCString: "NSEarlierTimeDesignations"];
NSFileDeviceIdentifier
= [[SClass alloc] initWithCString: "NSFileDeviceIdentifier"];
NSFileGroupOwnerAccountName
= [[SClass alloc] initWithCString: "NSFileGroupOwnerAccountName"];
NSFileGroupOwnerAccountNumber
= [[SClass alloc] initWithCString: "NSFileGroupOwnerAccountNumber"];
NSFileModificationDate
= [[SClass alloc] initWithCString: "NSFileModificationDate"];
NSFileOwnerAccountName
= [[SClass alloc] initWithCString: "NSFileOwnerAccountName"];
NSFileOwnerAccountNumber
= [[SClass alloc] initWithCString: "NSFileOwnerAccountNumber"];
NSFilePosixPermissions
= [[SClass alloc] initWithCString: "NSFilePosixPermissions"];
NSFileReferenceCount
= [[SClass alloc] initWithCString: "NSFileReferenceCount"];
NSFileSize
= [[SClass alloc] initWithCString: "NSFileSize"];
NSFileSystemFileNumber
= [[SClass alloc] initWithCString: "NSFileSystemFileNumber"];
NSFileSystemFreeNodes
= [[SClass alloc] initWithCString: "NSFileSystemFreeNodes"];
NSFileSystemFreeSize
= [[SClass alloc] initWithCString: "NSFileSystemFreeSize"];
NSFileSystemNodes
= [[SClass alloc] initWithCString: "NSFileSystemNodes"];
NSFileSystemNumber
= [[SClass alloc] initWithCString: "NSFileSystemNumber"];
NSFileSystemSize
= [[SClass alloc] initWithCString: "NSFileSystemSize"];
NSFileType
= [[SClass alloc] initWithCString: "NSFileType"];
NSFileTypeBlockSpecial
= [[SClass alloc] initWithCString: "NSFileTypeBlockSpecial"];
NSFileTypeCharacterSpecial
= [[SClass alloc] initWithCString: "NSFileTypeCharacterSpecial"];
NSFileTypeDirectory
= [[SClass alloc] initWithCString: "NSFileTypeDirectory"];
NSFileTypeFifo
= [[SClass alloc] initWithCString: "NSFileTypeFifo"];
NSFileTypeRegular
= [[SClass alloc] initWithCString: "NSFileTypeRegular"];
NSFileTypeSocket
= [[SClass alloc] initWithCString: "NSFileTypeSocket"];
NSFileTypeSymbolicLink
= [[SClass alloc] initWithCString: "NSFileTypeSymbolicLink"];
NSFileTypeUnknown
= [[SClass alloc] initWithCString: "NSFileTypeUnknown"];
NSFormalName NSFormalName
= [[SClass alloc] initWithCString: "NSFormalName"]; = [[SClass alloc] initWithCString: "NSFormalName"];
NSGlobalDomain NSGlobalDomain