Port xpcom to 64-bit Mac OS X, part 1. b=478687 r=mstange sr=bsmedberg

This commit is contained in:
Josh Aas 2009-03-06 12:32:57 -06:00
parent 016861a6f6
commit ffb320ce01
12 changed files with 96 additions and 219 deletions

View File

@ -1,7 +1,7 @@
/ * Double hashing implementation./a\ / * Double hashing implementation./a\
* GENERATED BY js/src/plify_jsdhash.sed -- DO NOT EDIT!!! \ * GENERATED BY js/src/plify_jsdhash.sed -- DO NOT EDIT!!!
/ * Double hashing, a la Knuth 6./a\ / * Double hashing, a la Knuth 6./a\
* GENERATED BY js/src/plify_jsdhash.sed -- DO NOT EDIT!!! \ * GENERATED BY js/src/plify_jsdhash.sed -- DO NOT EDIT!!!
s/jsdhash_h___/pldhash_h___/ s/jsdhash_h___/pldhash_h___/
s/jsdhash\.bigdump/pldhash.bigdump/ s/jsdhash\.bigdump/pldhash.bigdump/
s/jstypes\.h/nscore.h/ s/jstypes\.h/nscore.h/
@ -14,14 +14,18 @@ s/JS_DHASH/PL_DHASH/g
s/JS_DHash/PL_DHash/g s/JS_DHash/PL_DHash/g
s/JSDHash/PLDHash/g s/JSDHash/PLDHash/g
s/JSHash/PLHash/g s/JSHash/PLHash/g
s/uint32 /PRUint32/g s/uint8 /PRUint8/g
s/\([^U]\)int32 /\1PRInt32/g
s/uint16 /PRUint16/g s/uint16 /PRUint16/g
s/uint32 /PRUint32/g
s/\([^U]\)int8 /\1PRInt8/g
s/\([^U]\)int16 /\1PRInt16/g s/\([^U]\)int16 /\1PRInt16/g
s/uint32/PRUint32/g s/\([^U]\)int32 /\1PRInt32/g
s/\([^U]\)int32/\1PRInt32/g s/uint8/PRUint8/g
s/uint16/PRUint16/g s/uint16/PRUint16/g
s/uint32/PRUint32/g
s/\([^U]\)int8/\1PRInt8/g
s/\([^U]\)int16/\1PRInt16/g s/\([^U]\)int16/\1PRInt16/g
s/\([^U]\)int32/\1PRInt32/g
s/JSBool/PRBool/g s/JSBool/PRBool/g
s/extern JS_PUBLIC_API(\([^()]*\))/NS_COM_GLUE \1/ s/extern JS_PUBLIC_API(\([^()]*\))/NS_COM_GLUE \1/
s/JS_PUBLIC_API(\([^()]*\))/\1/ s/JS_PUBLIC_API(\([^()]*\))/\1/

View File

@ -899,33 +899,6 @@ FileSystemDataSource::GetVolumeList(nsISimpleEnumerator** aResult)
nsCOMPtr<nsIRDFResource> vol; nsCOMPtr<nsIRDFResource> vol;
#ifdef XP_MAC
StrFileName fname;
HParamBlockRec pb;
for (int16 volNum = 1; ; volNum++)
{
pb.volumeParam.ioCompletion = NULL;
pb.volumeParam.ioVolIndex = volNum;
pb.volumeParam.ioNamePtr = (StringPtr)fname;
if (PBHGetVInfo(&pb,FALSE) != noErr)
break;
FSSpec fss(pb.volumeParam.ioVRefNum, fsRtParID, fname);
nsCOMPtr<nsILocalFileMac> lf;
NS_NewLocalFileWithFSSpec(fss, true, getter_AddRefs(lf));
nsCOMPtr<nsIURI> furi;
NS_NewFileURI(getter_AddRefs(furi), lf);
nsXPIDLCString spec;
furi->GetSpec(getter_Copies(spec);
rv = mRDFService->GetResource(spec, getter_AddRefs(vol));
if (NS_FAILED(rv)) return rv;
volumes->AppendElement(vol);
}
#endif
#if defined (XP_WIN) && !defined (WINCE) #if defined (XP_WIN) && !defined (WINCE)
PRInt32 driveType; PRInt32 driveType;

View File

@ -158,23 +158,17 @@ SetupMacApplicationDelegate()
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN; NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
FSRef ref; FSRef ref;
FSSpec spec;
// The cast is kind of freaky, but apparently it's what all the beautiful people do. // The cast is kind of freaky, but apparently it's what all the beautiful people do.
OSStatus status = FSPathMakeRef((UInt8 *)[filename fileSystemRepresentation], &ref, NULL); OSStatus status = FSPathMakeRef((UInt8 *)[filename fileSystemRepresentation], &ref, NULL);
if (status != noErr) { if (status != noErr) {
NS_WARNING("FSPathMakeRef in openFile failed, skipping file open"); NS_WARNING("FSPathMakeRef in openFile failed, skipping file open");
return NO; return NO;
} }
status = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, &spec, NULL);
if (status != noErr) {
NS_WARNING("FSGetCatalogInfo in openFile failed, skipping file open");
return NO;
}
// Take advantage of the existing "command line" code for Macs. // Take advantage of the existing "command line" code for Macs.
nsMacCommandLine& cmdLine = nsMacCommandLine::GetMacCommandLine(); nsMacCommandLine& cmdLine = nsMacCommandLine::GetMacCommandLine();
// We don't actually care about Mac filetypes in this context, just pass a placeholder. // We don't actually care about Mac filetypes in this context, just pass a placeholder.
cmdLine.HandleOpenOneDoc(spec, 'abcd'); cmdLine.HandleOpenOneDoc(&ref, 'abcd');
return YES; return YES;
@ -190,23 +184,17 @@ SetupMacApplicationDelegate()
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN; NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
FSRef ref; FSRef ref;
FSSpec spec;
// The cast is kind of freaky, but apparently it's what all the beautiful people do. // The cast is kind of freaky, but apparently it's what all the beautiful people do.
OSStatus status = FSPathMakeRef((UInt8 *)[filename fileSystemRepresentation], &ref, NULL); OSStatus status = FSPathMakeRef((UInt8 *)[filename fileSystemRepresentation], &ref, NULL);
if (status != noErr) { if (status != noErr) {
NS_WARNING("FSPathMakeRef in printFile failed, skipping printing"); NS_WARNING("FSPathMakeRef in printFile failed, skipping printing");
return NO; return NO;
} }
status = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, &spec, NULL);
if (status != noErr) {
NS_WARNING("FSGetCatalogInfo in printFile failed, skipping printing");
return NO;
}
// Take advantage of the existing "command line" code for Macs. // Take advantage of the existing "command line" code for Macs.
nsMacCommandLine& cmdLine = nsMacCommandLine::GetMacCommandLine(); nsMacCommandLine& cmdLine = nsMacCommandLine::GetMacCommandLine();
// We don't actually care about Mac filetypes in this context, just pass a placeholder. // We don't actually care about Mac filetypes in this context, just pass a placeholder.
cmdLine.HandlePrintOneDoc(spec, 'abcd'); cmdLine.HandlePrintOneDoc(&ref, 'abcd');
return YES; return YES;

View File

@ -212,16 +212,10 @@ nsresult nsMacCommandLine::AddToCommandLine(const char* inArgText)
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
nsresult nsMacCommandLine::AddToCommandLine(const char* inOptionString, const FSSpec& inFileSpec) nsresult nsMacCommandLine::AddToCommandLine(const char* inOptionString, const FSRef* inFSRef)
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
{ {
// Convert the filespec to a URL. Avoid using xpcom because this may be CFURLRef url = ::CFURLCreateFromFSRef(nsnull, inFSRef);
// called before xpcom startup.
FSRef fsRef;
if (::FSpMakeFSRef(&inFileSpec, &fsRef) != noErr)
return NS_ERROR_FAILURE;
CFURLRef url = ::CFURLCreateFromFSRef(nsnull, &fsRef);
if (!url) if (!url)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -264,11 +258,11 @@ nsresult nsMacCommandLine::AddToEnvironmentVars(const char* inArgText)
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
OSErr nsMacCommandLine::HandleOpenOneDoc(const FSSpec& inFileSpec, OSType inFileType) OSErr nsMacCommandLine::HandleOpenOneDoc(const FSRef* inFSRef, OSType inFileType)
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
{ {
nsCOMPtr<nsILocalFileMac> inFile; nsCOMPtr<nsILocalFileMac> inFile;
nsresult rv = NS_NewLocalFileWithFSSpec(&inFileSpec, PR_TRUE, getter_AddRefs(inFile)); nsresult rv = NS_NewLocalFileWithFSRef(inFSRef, PR_TRUE, getter_AddRefs(inFile));
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return errAEEventNotHandled; return errAEEventNotHandled;
@ -313,7 +307,7 @@ OSErr nsMacCommandLine::HandleOpenOneDoc(const FSSpec& inFileSpec, OSType inFile
// add a command-line "-url" argument to the global list. This means that if // add a command-line "-url" argument to the global list. This means that if
// the app is opened with documents on the mac, they'll be handled the same // the app is opened with documents on the mac, they'll be handled the same
// way as if they had been typed on the command line in Unix or DOS. // way as if they had been typed on the command line in Unix or DOS.
rv = AddToCommandLine("-url", inFileSpec); rv = AddToCommandLine("-url", inFSRef);
return (NS_SUCCEEDED(rv)) ? noErr : errAEEventNotHandled; return (NS_SUCCEEDED(rv)) ? noErr : errAEEventNotHandled;
} }
@ -343,7 +337,7 @@ OSErr nsMacCommandLine::HandleOpenOneDoc(const FSSpec& inFileSpec, OSType inFile
} }
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
OSErr nsMacCommandLine::HandlePrintOneDoc(const FSSpec& inFileSpec, OSType fileType) OSErr nsMacCommandLine::HandlePrintOneDoc(const FSRef* inFSRef, OSType fileType)
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
{ {
// If we are starting up the application, // If we are starting up the application,
@ -351,7 +345,7 @@ OSErr nsMacCommandLine::HandlePrintOneDoc(const FSSpec& inFileSpec, OSType fileT
// the app is opened with documents on the mac, they'll be handled the same // the app is opened with documents on the mac, they'll be handled the same
// way as if they had been typed on the command line in Unix or DOS. // way as if they had been typed on the command line in Unix or DOS.
if (!mStartedUp) if (!mStartedUp)
return AddToCommandLine("-print", inFileSpec); return AddToCommandLine("-print", inFSRef);
// Final case: we're not just starting up. How do we handle this? // Final case: we're not just starting up. How do we handle this?
NS_NOTYETIMPLEMENTED("Write Me"); NS_NOTYETIMPLEMENTED("Write Me");

View File

@ -65,11 +65,11 @@ public:
void SetupCommandLine(int& argc, char**& argv); void SetupCommandLine(int& argc, char**& argv);
nsresult AddToCommandLine(const char* inArgText); nsresult AddToCommandLine(const char* inArgText);
nsresult AddToCommandLine(const char* inOptionString, const FSSpec& inFileSpec); nsresult AddToCommandLine(const char* inOptionString, const FSRef* inFSRef);
nsresult AddToEnvironmentVars(const char* inArgText); nsresult AddToEnvironmentVars(const char* inArgText);
OSErr HandleOpenOneDoc(const FSSpec& inFileSpec, OSType inFileType); OSErr HandleOpenOneDoc(const FSRef* inFSRef, OSType inFileType);
OSErr HandlePrintOneDoc(const FSSpec& inFileSpec, OSType fileType); OSErr HandlePrintOneDoc(const FSRef* inFSRef, OSType fileType);
OSErr DispatchURLToNewBrowser(const char* url); OSErr DispatchURLToNewBrowser(const char* url);

View File

@ -258,8 +258,8 @@ PL_DHashTableInit(PLDHashTable *table, const PLDHashTableOps *ops, void *data,
if (capacity >= PL_DHASH_SIZE_LIMIT) if (capacity >= PL_DHASH_SIZE_LIMIT)
return PR_FALSE; return PR_FALSE;
table->hashShift = PL_DHASH_BITS - log2; table->hashShift = PL_DHASH_BITS - log2;
table->maxAlphaFrac = (uint8)(0x100 * PL_DHASH_DEFAULT_MAX_ALPHA); table->maxAlphaFrac = (PRUint8)(0x100 * PL_DHASH_DEFAULT_MAX_ALPHA);
table->minAlphaFrac = (uint8)(0x100 * PL_DHASH_DEFAULT_MIN_ALPHA); table->minAlphaFrac = (PRUint8)(0x100 * PL_DHASH_DEFAULT_MIN_ALPHA);
table->entrySize = entrySize; table->entrySize = entrySize;
table->entryCount = table->removedCount = 0; table->entryCount = table->removedCount = 0;
table->generation = 0; table->generation = 0;
@ -326,8 +326,8 @@ PL_DHashTableSetAlphaBounds(PLDHashTable *table,
minAlpha = (size * maxAlpha - PR_MAX(size / 256, 1)) / (2 * size); minAlpha = (size * maxAlpha - PR_MAX(size / 256, 1)) / (2 * size);
} }
table->maxAlphaFrac = (uint8)(maxAlpha * 256); table->maxAlphaFrac = (PRUint8)(maxAlpha * 256);
table->minAlphaFrac = (uint8)(minAlpha * 256); table->minAlphaFrac = (PRUint8)(minAlpha * 256);
} }
/* /*

View File

@ -196,8 +196,8 @@ struct PLDHashTable {
const PLDHashTableOps *ops; /* virtual operations, see below */ const PLDHashTableOps *ops; /* virtual operations, see below */
void *data; /* ops- and instance-specific data */ void *data; /* ops- and instance-specific data */
PRInt16 hashShift; /* multiplicative hash shift */ PRInt16 hashShift; /* multiplicative hash shift */
uint8 maxAlphaFrac; /* 8-bit fixed point max alpha */ PRUint8 maxAlphaFrac; /* 8-bit fixed point max alpha */
uint8 minAlphaFrac; /* 8-bit fixed point min alpha */ PRUint8 minAlphaFrac; /* 8-bit fixed point min alpha */
PRUint32 entrySize; /* number of bytes in an entry */ PRUint32 entrySize; /* number of bytes in an entry */
PRUint32 entryCount; /* number of entries in table */ PRUint32 entryCount; /* number of entries in table */
PRUint32 removedCount; /* removed entry sentinels in table */ PRUint32 removedCount; /* removed entry sentinels in table */
@ -457,7 +457,7 @@ PL_DHashTableSetAlphaBounds(PLDHashTable *table,
#define PL_DHASH_CAPACITY(entryCount, maxAlpha) \ #define PL_DHASH_CAPACITY(entryCount, maxAlpha) \
(PL_DHASH_CAP(entryCount, maxAlpha) + \ (PL_DHASH_CAP(entryCount, maxAlpha) + \
(((PL_DHASH_CAP(entryCount, maxAlpha) * (uint8)(0x100 * (maxAlpha))) \ (((PL_DHASH_CAP(entryCount, maxAlpha) * (PRUint8)(0x100 * (maxAlpha))) \
>> 8) < (entryCount))) >> 8) < (entryCount)))
#define PL_DHASH_DEFAULT_CAPACITY(entryCount) \ #define PL_DHASH_DEFAULT_CAPACITY(entryCount) \

View File

@ -94,7 +94,6 @@
#ifdef XP_MACOSX #ifdef XP_MACOSX
#define NS_MACOSX_USER_PLUGIN_DIR "OSXUserPlugins" #define NS_MACOSX_USER_PLUGIN_DIR "OSXUserPlugins"
#define NS_MACOSX_LOCAL_PLUGIN_DIR "OSXLocalPlugins" #define NS_MACOSX_LOCAL_PLUGIN_DIR "OSXLocalPlugins"
#define NS_MAC_CLASSIC_PLUGIN_DIR "MacSysPlugins"
#elif XP_UNIX #elif XP_UNIX
#define NS_SYSTEM_PLUGINS_DIR "SysPlugins" #define NS_SYSTEM_PLUGINS_DIR "SysPlugins"
#endif #endif
@ -136,9 +135,7 @@ nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistent, nsIFile
*persistent = PR_TRUE; *persistent = PR_TRUE;
#ifdef XP_MACOSX #ifdef XP_MACOSX
short foundVRefNum; FSRef fileRef;
long foundDirID;
FSSpec fileSpec;
nsCOMPtr<nsILocalFileMac> macFile; nsCOMPtr<nsILocalFileMac> macFile;
#endif #endif
@ -206,33 +203,16 @@ nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistent, nsIFile
#ifdef XP_MACOSX #ifdef XP_MACOSX
else if (nsCRT::strcmp(prop, NS_MACOSX_USER_PLUGIN_DIR) == 0) else if (nsCRT::strcmp(prop, NS_MACOSX_USER_PLUGIN_DIR) == 0)
{ {
if (!(::FindFolder(kUserDomain, if (::FSFindFolder(kUserDomain, kInternetPlugInFolderType, false, &fileRef) == noErr) {
kInternetPlugInFolderType, rv = NS_NewLocalFileWithFSRef(&fileRef, PR_TRUE, getter_AddRefs(macFile));
kDontCreateFolder, &foundVRefNum, &foundDirID)) &&
!(::FSMakeFSSpec(foundVRefNum, foundDirID, "\p", &fileSpec))) {
rv = NS_NewLocalFileWithFSSpec(&fileSpec, PR_TRUE, getter_AddRefs(macFile));
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
localFile = macFile; localFile = macFile;
} }
} }
else if (nsCRT::strcmp(prop, NS_MACOSX_LOCAL_PLUGIN_DIR) == 0) else if (nsCRT::strcmp(prop, NS_MACOSX_LOCAL_PLUGIN_DIR) == 0)
{ {
if (!(::FindFolder(kLocalDomain, if (::FSFindFolder(kLocalDomain, kInternetPlugInFolderType, false, &fileRef) == noErr) {
kInternetPlugInFolderType, rv = NS_NewLocalFileWithFSRef(&fileRef, PR_TRUE, getter_AddRefs(macFile));
kDontCreateFolder, &foundVRefNum, &foundDirID)) &&
!(::FSMakeFSSpec(foundVRefNum, foundDirID, "\p", &fileSpec))) {
rv = NS_NewLocalFileWithFSSpec(&fileSpec, PR_TRUE, getter_AddRefs(macFile));
if (NS_SUCCEEDED(rv))
localFile = macFile;
}
}
else if (nsCRT::strcmp(prop, NS_MAC_CLASSIC_PLUGIN_DIR) == 0)
{
if (!(::FindFolder(kOnAppropriateDisk,
kInternetPlugInFolderType,
kDontCreateFolder, &foundVRefNum, &foundDirID)) &&
!(::FSMakeFSSpec(foundVRefNum, foundDirID, "\p", &fileSpec))) {
rv = NS_NewLocalFileWithFSSpec(&fileSpec, PR_TRUE, getter_AddRefs(macFile));
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
localFile = macFile; localFile = macFile;
} }
@ -579,17 +559,7 @@ nsAppFileLocationProvider::GetFiles(const char *prop, nsISimpleEnumerator **_ret
if (!nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR_LIST)) if (!nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR_LIST))
{ {
#ifdef XP_MACOSX #ifdef XP_MACOSX
static const char* osXKeys[] = { NS_APP_PLUGINS_DIR, NS_MACOSX_USER_PLUGIN_DIR, NS_MACOSX_LOCAL_PLUGIN_DIR, nsnull }; static const char* keys[] = { NS_APP_PLUGINS_DIR, NS_MACOSX_USER_PLUGIN_DIR, NS_MACOSX_LOCAL_PLUGIN_DIR, nsnull };
static const char* os9Keys[] = { NS_APP_PLUGINS_DIR, NS_MAC_CLASSIC_PLUGIN_DIR, nsnull };
static const char** keys;
if (!keys) {
OSErr err;
long response;
err = ::Gestalt(gestaltSystemVersion, &response);
keys = (!err && response >= 0x00001000) ? osXKeys : os9Keys;
}
*_retval = new nsAppDirectoryEnumerator(this, keys); *_retval = new nsAppDirectoryEnumerator(this, keys);
#else #else
#ifdef XP_UNIX #ifdef XP_UNIX

View File

@ -51,7 +51,7 @@
[ptr] native FSRefPtr(FSRef); [ptr] native FSRefPtr(FSRef);
native CFURLRef(CFURLRef); native CFURLRef(CFURLRef);
[scriptable, uuid(748f3ffe-27d9-4402-9de9-494badbeebf4)] [scriptable, uuid(7224E826-3F6C-4BB2-9C6E-02DA44575743)]
interface nsILocalFileMac : nsILocalFile interface nsILocalFileMac : nsILocalFile
{ {
/** /**
@ -79,17 +79,6 @@ interface nsILocalFileMac : nsILocalFile
*/ */
[noscript] void initWithFSRef([const] in FSRefPtr aFSRef); [noscript] void initWithFSRef([const] in FSRefPtr aFSRef);
/**
* initWithFSSpec
*
* Init this object with an FSSpec
* Legacy method - leaving in place for now
*
* @param aFileSpec the native file spec
*
*/
[noscript] void initWithFSSpec([const] in FSSpecPtr aFileSpec);
/** /**
* initToAppWithCreatorCode * initToAppWithCreatorCode
* *
@ -249,14 +238,6 @@ interface nsILocalFileMac : nsILocalFile
%{C++ %{C++
extern "C" extern "C"
{ {
#ifndef XP_MACOSX
NS_EXPORT const char* NS_TruncNodeName(const char *aNode, char *outBuf);
#endif
NS_EXPORT nsresult NS_NewLocalFileWithFSSpec(const FSSpec* inSpec, PRBool followSymlinks, nsILocalFileMac* *result);
// NS_NewLocalFileWithFSRef is available since Mozilla 1.8.1.
NS_EXPORT nsresult NS_NewLocalFileWithFSRef(const FSRef* aFSRef, PRBool aFollowSymlinks, nsILocalFileMac** result); NS_EXPORT nsresult NS_NewLocalFileWithFSRef(const FSRef* aFSRef, PRBool aFollowSymlinks, nsILocalFileMac** result);
} }
%} %}

View File

@ -757,25 +757,31 @@ NS_IMETHODIMP nsLocalFile::Remove(PRBool recursive)
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT; NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
} }
// Only send back permissions bits: maybe we want to send back the whole
// mode_t to permit checks against other file types?
#define NORMALIZE_PERMS(mode) ((mode)& (S_IRWXU | S_IRWXG | S_IRWXO))
NS_IMETHODIMP nsLocalFile::GetPermissions(PRUint32 *aPermissions) NS_IMETHODIMP nsLocalFile::GetPermissions(PRUint32 *aPermissions)
{ {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
NS_ENSURE_ARG_POINTER(aPermissions); NS_ENSURE_ARG_POINTER(aPermissions);
FSRef fsRef; CHECK_mBaseRef();
nsresult rv = GetFSRefInternal(fsRef);
if (NS_FAILED(rv)) NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
return rv; NSDictionary *fileAttributes = [[NSFileManager defaultManager] fileAttributesAtPath:[(NSURL*)mBaseRef path] traverseLink:YES];
if (fileAttributes) {
FSCatalogInfo catalogInfo; NSNumber *permissions = [fileAttributes objectForKey:NSFilePosixPermissions];
OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoPermissions, &catalogInfo, if (permissions) {
nsnull, nsnull, nsnull); *aPermissions = NORMALIZE_PERMS([permissions unsignedLongValue]);
if (err != noErr) [ap release];
return MacErrorMapper(err); return NS_OK;
FSPermissionInfo *permPtr = (FSPermissionInfo*)catalogInfo.permissions; }
*aPermissions = permPtr->mode; }
return NS_OK; [ap release];
return NS_ERROR_FAILURE;
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT; NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
} }
@ -784,20 +790,15 @@ NS_IMETHODIMP nsLocalFile::SetPermissions(PRUint32 aPermissions)
{ {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
FSRef fsRef; CHECK_mBaseRef();
nsresult rv = GetFSRefInternal(fsRef);
if (NS_FAILED(rv)) NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
return rv; NSNumber* pNumber = [NSNumber numberWithUnsignedInt:aPermissions];
NSDictionary* fileAttributes = [NSDictionary dictionaryWithObject:pNumber forKey:NSFilePosixPermissions];
FSCatalogInfo catalogInfo; // changeFileAttributes:atPath: follows symbolic links though the documentation doesn't mention it
OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoPermissions, &catalogInfo, BOOL success = [[NSFileManager defaultManager] changeFileAttributes:fileAttributes atPath:[(NSURL*)mBaseRef path]];
nsnull, nsnull, nsnull); [ap release];
if (err != noErr) return (success ? NS_OK : NS_ERROR_FAILURE);
return MacErrorMapper(err);
FSPermissionInfo *permPtr = (FSPermissionInfo*)catalogInfo.permissions;
permPtr->mode = (UInt16)aPermissions;
err = ::FSSetCatalogInfo(&fsRef, kFSCatInfoPermissions, &catalogInfo);
return MacErrorMapper(err);
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT; NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
} }
@ -932,7 +933,7 @@ NS_IMETHODIMP nsLocalFile::SetFileSize(PRInt64 aFileSize)
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
SInt16 refNum; FSIORefNum refNum;
OSErr err = ::FSOpenFork(&fsRef, 0, nsnull, fsWrPerm, &refNum); OSErr err = ::FSOpenFork(&fsRef, 0, nsnull, fsWrPerm, &refNum);
if (err != noErr) if (err != noErr)
return MacErrorMapper(err); return MacErrorMapper(err);
@ -1731,22 +1732,6 @@ NS_IMETHODIMP nsLocalFile::InitWithFSRef(const FSRef *aFSRef)
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT; NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
} }
NS_IMETHODIMP nsLocalFile::InitWithFSSpec(const FSSpec *aFileSpec)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
NS_ENSURE_ARG(aFileSpec);
FSRef fsRef;
OSErr err = ::FSpMakeFSRef(aFileSpec, &fsRef);
if (err == noErr)
return InitWithFSRef(&fsRef);
return MacErrorMapper(err);
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
}
NS_IMETHODIMP nsLocalFile::InitToAppWithCreatorCode(OSType aAppCreator) NS_IMETHODIMP nsLocalFile::InitToAppWithCreatorCode(OSType aAppCreator)
{ {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
@ -2350,24 +2335,6 @@ nsresult NS_NewNativeLocalFile(const nsACString& path, PRBool followLinks, nsILo
return NS_NewLocalFile(NS_ConvertUTF8toUTF16(path), followLinks, result); return NS_NewLocalFile(NS_ConvertUTF8toUTF16(path), followLinks, result);
} }
nsresult NS_NewLocalFileWithFSSpec(const FSSpec* inSpec, PRBool followLinks, nsILocalFileMac **result)
{
nsLocalFile* file = new nsLocalFile();
if (file == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(file);
file->SetFollowLinks(followLinks);
nsresult rv = file->InitWithFSSpec(inSpec);
if (NS_FAILED(rv)) {
NS_RELEASE(file);
return rv;
}
*result = file;
return NS_OK;
}
nsresult NS_NewLocalFileWithFSRef(const FSRef* aFSRef, PRBool aFollowLinks, nsILocalFileMac** result) nsresult NS_NewLocalFileWithFSRef(const FSRef* aFSRef, PRBool aFollowLinks, nsILocalFileMac** result)
{ {
nsLocalFile* file = new nsLocalFile(); nsLocalFile* file = new nsLocalFile();

View File

@ -59,16 +59,16 @@ public:
nsXPTType(const XPTTypeDescriptorPrefix& prefix) nsXPTType(const XPTTypeDescriptorPrefix& prefix)
{*(XPTTypeDescriptorPrefix*)this = prefix;} {*(XPTTypeDescriptorPrefix*)this = prefix;}
nsXPTType(const uint8& prefix) nsXPTType(const PRUint8& prefix)
{*(uint8*)this = prefix;} {*(PRUint8*)this = prefix;}
nsXPTType& operator=(uint8 val) nsXPTType& operator=(PRUint8 val)
{flags = val; return *this;} {flags = val; return *this;}
nsXPTType& operator=(const nsXPTType& other) nsXPTType& operator=(const nsXPTType& other)
{flags = other.flags; return *this;} {flags = other.flags; return *this;}
operator uint8() const operator PRUint8() const
{return flags;} {return flags;}
PRBool IsPointer() const PRBool IsPointer() const
@ -111,8 +111,8 @@ public:
} }
} }
uint8 TagPart() const PRUint8 TagPart() const
{return (uint8) (flags & XPT_TDP_TAGMASK);} {return (PRUint8) (flags & XPT_TDP_TAGMASK);}
enum enum
{ {
@ -182,9 +182,9 @@ public:
PRBool IsConstructor() const {return 0 != (XPT_MD_IS_CTOR(flags) );} PRBool IsConstructor() const {return 0 != (XPT_MD_IS_CTOR(flags) );}
PRBool IsHidden() const {return 0 != (XPT_MD_IS_HIDDEN(flags) );} PRBool IsHidden() const {return 0 != (XPT_MD_IS_HIDDEN(flags) );}
const char* GetName() const {return name;} const char* GetName() const {return name;}
uint8 GetParamCount() const {return num_args;} PRUint8 GetParamCount() const {return num_args;}
/* idx was index before I got _sick_ of the warnings on Unix, sorry jband */ /* idx was index before I got _sick_ of the warnings on Unix, sorry jband */
const nsXPTParamInfo GetParam(uint8 idx) const const nsXPTParamInfo GetParam(PRUint8 idx) const
{ {
NS_PRECONDITION(idx < GetParamCount(),"bad arg"); NS_PRECONDITION(idx < GetParamCount(),"bad arg");
return params[idx]; return params[idx];

View File

@ -121,14 +121,14 @@ public:
// No ctors or dtors so that we can be in a union in xptiInterfaceInfo. // No ctors or dtors so that we can be in a union in xptiInterfaceInfo.
// Allow automatic shallow copies. // Allow automatic shallow copies.
uint16 GetFileIndex() const {return mFileIndex;} PRUint16 GetFileIndex() const {return mFileIndex;}
uint16 GetZipItemIndex() const {return mZipItemIndex;} PRUint16 GetZipItemIndex() const {return mZipItemIndex;}
enum {NOT_ZIP = 0xffff}; enum {NOT_ZIP = 0xffff};
PRBool IsZip() const {return mZipItemIndex != NOT_ZIP;} PRBool IsZip() const {return mZipItemIndex != NOT_ZIP;}
void Init(uint16 aFileIndex, uint16 aZipItemIndex = NOT_ZIP) void Init(PRUint16 aFileIndex, PRUint16 aZipItemIndex = NOT_ZIP)
{mFileIndex = aFileIndex; mZipItemIndex = aZipItemIndex;} {mFileIndex = aFileIndex; mZipItemIndex = aZipItemIndex;}
PRBool Equals(const xptiTypelib& r) const PRBool Equals(const xptiTypelib& r) const
@ -136,8 +136,8 @@ public:
mZipItemIndex == r.mZipItemIndex;} mZipItemIndex == r.mZipItemIndex;}
private: private:
uint16 mFileIndex; PRUint16 mFileIndex;
uint16 mZipItemIndex; PRUint16 mZipItemIndex;
}; };
/***************************************************************************/ /***************************************************************************/
@ -448,8 +448,8 @@ public:
class xptiInterfaceGuts class xptiInterfaceGuts
{ {
public: public:
uint16 mMethodBaseIndex; PRUint16 mMethodBaseIndex;
uint16 mConstantBaseIndex; PRUint16 mConstantBaseIndex;
xptiInterfaceEntry* mParent; xptiInterfaceEntry* mParent;
XPTInterfaceDescriptor* mDescriptor; XPTInterfaceDescriptor* mDescriptor;
xptiTypelib mTypelib; xptiTypelib mTypelib;
@ -490,35 +490,35 @@ class xptiInfoFlags
{ {
enum {STATE_MASK = 3}; enum {STATE_MASK = 3};
public: public:
xptiInfoFlags(uint8 n) : mData(n) {} xptiInfoFlags(PRUint8 n) : mData(n) {}
xptiInfoFlags(const xptiInfoFlags& r) : mData(r.mData) {} xptiInfoFlags(const xptiInfoFlags& r) : mData(r.mData) {}
static uint8 GetStateMask() static PRUint8 GetStateMask()
{return uint8(STATE_MASK);} {return PRUint8(STATE_MASK);}
void Clear() void Clear()
{mData = 0;} {mData = 0;}
uint8 GetData() const PRUint8 GetData() const
{return mData;} {return mData;}
uint8 GetState() const PRUint8 GetState() const
{return mData & GetStateMask();} {return mData & GetStateMask();}
void SetState(uint8 state) void SetState(PRUint8 state)
{mData &= ~GetStateMask(); mData |= state;} {mData &= ~GetStateMask(); mData |= state;}
void SetFlagBit(uint8 flag, PRBool on) void SetFlagBit(PRUint8 flag, PRBool on)
{if(on) {if(on)
mData |= ~GetStateMask() & flag; mData |= ~GetStateMask() & flag;
else else
mData &= GetStateMask() | ~flag;} mData &= GetStateMask() | ~flag;}
PRBool GetFlagBit(uint8 flag) const PRBool GetFlagBit(PRUint8 flag) const
{return (mData & flag) ? PR_TRUE : PR_FALSE;} {return (mData & flag) ? PR_TRUE : PR_FALSE;}
private: private:
uint8 mData; PRUint8 mData;
}; };
/****************************************************/ /****************************************************/
@ -550,10 +550,10 @@ public:
// Additional bit flags... // Additional bit flags...
enum {SCRIPTABLE = 4}; enum {SCRIPTABLE = 4};
uint8 GetResolveState() const {return mFlags.GetState();} PRUint8 GetResolveState() const {return mFlags.GetState();}
PRBool IsFullyResolved() const PRBool IsFullyResolved() const
{return GetResolveState() == (uint8) FULLY_RESOLVED;} {return GetResolveState() == (PRUint8) FULLY_RESOLVED;}
PRBool HasInterfaceRecord() const PRBool HasInterfaceRecord() const
{int s = (int) GetResolveState(); {int s = (int) GetResolveState();
@ -579,9 +579,9 @@ public:
#endif #endif
void SetScriptableFlag(PRBool on) void SetScriptableFlag(PRBool on)
{mFlags.SetFlagBit(uint8(SCRIPTABLE),on);} {mFlags.SetFlagBit(PRUint8(SCRIPTABLE),on);}
PRBool GetScriptableFlag() const PRBool GetScriptableFlag() const
{return mFlags.GetFlagBit(uint8(SCRIPTABLE));} {return mFlags.GetFlagBit(PRUint8(SCRIPTABLE));}
const nsID* GetTheIID() const {return &mIID;} const nsID* GetTheIID() const {return &mIID;}
const char* GetTheName() const {return mName;} const char* GetTheName() const {return mName;}
@ -645,7 +645,7 @@ private:
void* operator new(size_t, void* p) CPP_THROW_NEW {return p;} void* operator new(size_t, void* p) CPP_THROW_NEW {return p;}
void SetResolvedState(int state) void SetResolvedState(int state)
{mFlags.SetState(uint8(state));} {mFlags.SetState(PRUint8(state));}
PRBool Resolve(xptiWorkingSet* aWorkingSet = nsnull); PRBool Resolve(xptiWorkingSet* aWorkingSet = nsnull);
@ -664,7 +664,7 @@ private:
xptiInterfaceEntry** entry); xptiInterfaceEntry** entry);
nsresult GetTypeInArray(const nsXPTParamInfo* param, nsresult GetTypeInArray(const nsXPTParamInfo* param,
uint16 dimension, PRUint16 dimension,
const XPTTypeDescriptor** type); const XPTTypeDescriptor** type);
private: private: