зеркало из https://github.com/mozilla/gecko-dev.git
Port xpcom to 64-bit Mac OS X, part 1. b=478687 r=mstange sr=bsmedberg
This commit is contained in:
Родитель
016861a6f6
Коммит
ffb320ce01
|
@ -1,7 +1,7 @@
|
|||
/ * 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\
|
||||
* 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\.bigdump/pldhash.bigdump/
|
||||
s/jstypes\.h/nscore.h/
|
||||
|
@ -14,14 +14,18 @@ s/JS_DHASH/PL_DHASH/g
|
|||
s/JS_DHash/PL_DHash/g
|
||||
s/JSDHash/PLDHash/g
|
||||
s/JSHash/PLHash/g
|
||||
s/uint32 /PRUint32/g
|
||||
s/\([^U]\)int32 /\1PRInt32/g
|
||||
s/uint8 /PRUint8/g
|
||||
s/uint16 /PRUint16/g
|
||||
s/uint32 /PRUint32/g
|
||||
s/\([^U]\)int8 /\1PRInt8/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/uint32/PRUint32/g
|
||||
s/\([^U]\)int8/\1PRInt8/g
|
||||
s/\([^U]\)int16/\1PRInt16/g
|
||||
s/\([^U]\)int32/\1PRInt32/g
|
||||
s/JSBool/PRBool/g
|
||||
s/extern JS_PUBLIC_API(\([^()]*\))/NS_COM_GLUE \1/
|
||||
s/JS_PUBLIC_API(\([^()]*\))/\1/
|
||||
|
|
|
@ -899,33 +899,6 @@ FileSystemDataSource::GetVolumeList(nsISimpleEnumerator** aResult)
|
|||
|
||||
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)
|
||||
|
||||
PRInt32 driveType;
|
||||
|
|
|
@ -158,23 +158,17 @@ SetupMacApplicationDelegate()
|
|||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
||||
|
||||
FSRef ref;
|
||||
FSSpec spec;
|
||||
// The cast is kind of freaky, but apparently it's what all the beautiful people do.
|
||||
OSStatus status = FSPathMakeRef((UInt8 *)[filename fileSystemRepresentation], &ref, NULL);
|
||||
if (status != noErr) {
|
||||
NS_WARNING("FSPathMakeRef in openFile failed, skipping file open");
|
||||
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.
|
||||
nsMacCommandLine& cmdLine = nsMacCommandLine::GetMacCommandLine();
|
||||
// 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;
|
||||
|
||||
|
@ -190,23 +184,17 @@ SetupMacApplicationDelegate()
|
|||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
||||
|
||||
FSRef ref;
|
||||
FSSpec spec;
|
||||
// The cast is kind of freaky, but apparently it's what all the beautiful people do.
|
||||
OSStatus status = FSPathMakeRef((UInt8 *)[filename fileSystemRepresentation], &ref, NULL);
|
||||
if (status != noErr) {
|
||||
NS_WARNING("FSPathMakeRef in printFile failed, skipping printing");
|
||||
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.
|
||||
nsMacCommandLine& cmdLine = nsMacCommandLine::GetMacCommandLine();
|
||||
// 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;
|
||||
|
||||
|
|
|
@ -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
|
||||
// called before xpcom startup.
|
||||
FSRef fsRef;
|
||||
if (::FSpMakeFSRef(&inFileSpec, &fsRef) != noErr)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
CFURLRef url = ::CFURLCreateFromFSRef(nsnull, &fsRef);
|
||||
CFURLRef url = ::CFURLCreateFromFSRef(nsnull, inFSRef);
|
||||
if (!url)
|
||||
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;
|
||||
nsresult rv = NS_NewLocalFileWithFSSpec(&inFileSpec, PR_TRUE, getter_AddRefs(inFile));
|
||||
nsresult rv = NS_NewLocalFileWithFSRef(inFSRef, PR_TRUE, getter_AddRefs(inFile));
|
||||
if (NS_FAILED(rv))
|
||||
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
|
||||
// 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.
|
||||
rv = AddToCommandLine("-url", inFileSpec);
|
||||
rv = AddToCommandLine("-url", inFSRef);
|
||||
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,
|
||||
|
@ -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
|
||||
// way as if they had been typed on the command line in Unix or DOS.
|
||||
if (!mStartedUp)
|
||||
return AddToCommandLine("-print", inFileSpec);
|
||||
return AddToCommandLine("-print", inFSRef);
|
||||
|
||||
// Final case: we're not just starting up. How do we handle this?
|
||||
NS_NOTYETIMPLEMENTED("Write Me");
|
||||
|
|
|
@ -65,11 +65,11 @@ public:
|
|||
void SetupCommandLine(int& argc, char**& argv);
|
||||
|
||||
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);
|
||||
|
||||
OSErr HandleOpenOneDoc(const FSSpec& inFileSpec, OSType inFileType);
|
||||
OSErr HandlePrintOneDoc(const FSSpec& inFileSpec, OSType fileType);
|
||||
OSErr HandleOpenOneDoc(const FSRef* inFSRef, OSType inFileType);
|
||||
OSErr HandlePrintOneDoc(const FSRef* inFSRef, OSType fileType);
|
||||
|
||||
OSErr DispatchURLToNewBrowser(const char* url);
|
||||
|
||||
|
|
|
@ -258,8 +258,8 @@ PL_DHashTableInit(PLDHashTable *table, const PLDHashTableOps *ops, void *data,
|
|||
if (capacity >= PL_DHASH_SIZE_LIMIT)
|
||||
return PR_FALSE;
|
||||
table->hashShift = PL_DHASH_BITS - log2;
|
||||
table->maxAlphaFrac = (uint8)(0x100 * PL_DHASH_DEFAULT_MAX_ALPHA);
|
||||
table->minAlphaFrac = (uint8)(0x100 * PL_DHASH_DEFAULT_MIN_ALPHA);
|
||||
table->maxAlphaFrac = (PRUint8)(0x100 * PL_DHASH_DEFAULT_MAX_ALPHA);
|
||||
table->minAlphaFrac = (PRUint8)(0x100 * PL_DHASH_DEFAULT_MIN_ALPHA);
|
||||
table->entrySize = entrySize;
|
||||
table->entryCount = table->removedCount = 0;
|
||||
table->generation = 0;
|
||||
|
@ -326,8 +326,8 @@ PL_DHashTableSetAlphaBounds(PLDHashTable *table,
|
|||
minAlpha = (size * maxAlpha - PR_MAX(size / 256, 1)) / (2 * size);
|
||||
}
|
||||
|
||||
table->maxAlphaFrac = (uint8)(maxAlpha * 256);
|
||||
table->minAlphaFrac = (uint8)(minAlpha * 256);
|
||||
table->maxAlphaFrac = (PRUint8)(maxAlpha * 256);
|
||||
table->minAlphaFrac = (PRUint8)(minAlpha * 256);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -196,8 +196,8 @@ struct PLDHashTable {
|
|||
const PLDHashTableOps *ops; /* virtual operations, see below */
|
||||
void *data; /* ops- and instance-specific data */
|
||||
PRInt16 hashShift; /* multiplicative hash shift */
|
||||
uint8 maxAlphaFrac; /* 8-bit fixed point max alpha */
|
||||
uint8 minAlphaFrac; /* 8-bit fixed point min alpha */
|
||||
PRUint8 maxAlphaFrac; /* 8-bit fixed point max alpha */
|
||||
PRUint8 minAlphaFrac; /* 8-bit fixed point min alpha */
|
||||
PRUint32 entrySize; /* number of bytes in an entry */
|
||||
PRUint32 entryCount; /* number of entries in table */
|
||||
PRUint32 removedCount; /* removed entry sentinels in table */
|
||||
|
@ -457,7 +457,7 @@ PL_DHashTableSetAlphaBounds(PLDHashTable *table,
|
|||
|
||||
#define PL_DHASH_CAPACITY(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)))
|
||||
|
||||
#define PL_DHASH_DEFAULT_CAPACITY(entryCount) \
|
||||
|
|
|
@ -94,7 +94,6 @@
|
|||
#ifdef XP_MACOSX
|
||||
#define NS_MACOSX_USER_PLUGIN_DIR "OSXUserPlugins"
|
||||
#define NS_MACOSX_LOCAL_PLUGIN_DIR "OSXLocalPlugins"
|
||||
#define NS_MAC_CLASSIC_PLUGIN_DIR "MacSysPlugins"
|
||||
#elif XP_UNIX
|
||||
#define NS_SYSTEM_PLUGINS_DIR "SysPlugins"
|
||||
#endif
|
||||
|
@ -136,9 +135,7 @@ nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistent, nsIFile
|
|||
*persistent = PR_TRUE;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
short foundVRefNum;
|
||||
long foundDirID;
|
||||
FSSpec fileSpec;
|
||||
FSRef fileRef;
|
||||
nsCOMPtr<nsILocalFileMac> macFile;
|
||||
#endif
|
||||
|
||||
|
@ -206,33 +203,16 @@ nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistent, nsIFile
|
|||
#ifdef XP_MACOSX
|
||||
else if (nsCRT::strcmp(prop, NS_MACOSX_USER_PLUGIN_DIR) == 0)
|
||||
{
|
||||
if (!(::FindFolder(kUserDomain,
|
||||
kInternetPlugInFolderType,
|
||||
kDontCreateFolder, &foundVRefNum, &foundDirID)) &&
|
||||
!(::FSMakeFSSpec(foundVRefNum, foundDirID, "\p", &fileSpec))) {
|
||||
rv = NS_NewLocalFileWithFSSpec(&fileSpec, PR_TRUE, getter_AddRefs(macFile));
|
||||
if (::FSFindFolder(kUserDomain, kInternetPlugInFolderType, false, &fileRef) == noErr) {
|
||||
rv = NS_NewLocalFileWithFSRef(&fileRef, PR_TRUE, getter_AddRefs(macFile));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
localFile = macFile;
|
||||
}
|
||||
}
|
||||
else if (nsCRT::strcmp(prop, NS_MACOSX_LOCAL_PLUGIN_DIR) == 0)
|
||||
{
|
||||
if (!(::FindFolder(kLocalDomain,
|
||||
kInternetPlugInFolderType,
|
||||
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 (::FSFindFolder(kLocalDomain, kInternetPlugInFolderType, false, &fileRef) == noErr) {
|
||||
rv = NS_NewLocalFileWithFSRef(&fileRef, PR_TRUE, getter_AddRefs(macFile));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
localFile = macFile;
|
||||
}
|
||||
|
@ -579,17 +559,7 @@ nsAppFileLocationProvider::GetFiles(const char *prop, nsISimpleEnumerator **_ret
|
|||
if (!nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR_LIST))
|
||||
{
|
||||
#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* 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;
|
||||
}
|
||||
|
||||
static const char* keys[] = { NS_APP_PLUGINS_DIR, NS_MACOSX_USER_PLUGIN_DIR, NS_MACOSX_LOCAL_PLUGIN_DIR, nsnull };
|
||||
*_retval = new nsAppDirectoryEnumerator(this, keys);
|
||||
#else
|
||||
#ifdef XP_UNIX
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
[ptr] native FSRefPtr(FSRef);
|
||||
native CFURLRef(CFURLRef);
|
||||
|
||||
[scriptable, uuid(748f3ffe-27d9-4402-9de9-494badbeebf4)]
|
||||
[scriptable, uuid(7224E826-3F6C-4BB2-9C6E-02DA44575743)]
|
||||
interface nsILocalFileMac : nsILocalFile
|
||||
{
|
||||
/**
|
||||
|
@ -79,17 +79,6 @@ interface nsILocalFileMac : nsILocalFile
|
|||
*/
|
||||
[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
|
||||
*
|
||||
|
@ -249,14 +238,6 @@ interface nsILocalFileMac : nsILocalFile
|
|||
%{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);
|
||||
}
|
||||
%}
|
||||
|
|
|
@ -757,25 +757,31 @@ NS_IMETHODIMP nsLocalFile::Remove(PRBool recursive)
|
|||
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_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aPermissions);
|
||||
|
||||
FSRef fsRef;
|
||||
nsresult rv = GetFSRefInternal(fsRef);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
FSCatalogInfo catalogInfo;
|
||||
OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoPermissions, &catalogInfo,
|
||||
nsnull, nsnull, nsnull);
|
||||
if (err != noErr)
|
||||
return MacErrorMapper(err);
|
||||
FSPermissionInfo *permPtr = (FSPermissionInfo*)catalogInfo.permissions;
|
||||
*aPermissions = permPtr->mode;
|
||||
return NS_OK;
|
||||
|
||||
CHECK_mBaseRef();
|
||||
|
||||
NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
|
||||
NSDictionary *fileAttributes = [[NSFileManager defaultManager] fileAttributesAtPath:[(NSURL*)mBaseRef path] traverseLink:YES];
|
||||
if (fileAttributes) {
|
||||
NSNumber *permissions = [fileAttributes objectForKey:NSFilePosixPermissions];
|
||||
if (permissions) {
|
||||
*aPermissions = NORMALIZE_PERMS([permissions unsignedLongValue]);
|
||||
[ap release];
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
[ap release];
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
@ -784,20 +790,15 @@ NS_IMETHODIMP nsLocalFile::SetPermissions(PRUint32 aPermissions)
|
|||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
FSRef fsRef;
|
||||
nsresult rv = GetFSRefInternal(fsRef);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
FSCatalogInfo catalogInfo;
|
||||
OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoPermissions, &catalogInfo,
|
||||
nsnull, nsnull, nsnull);
|
||||
if (err != noErr)
|
||||
return MacErrorMapper(err);
|
||||
FSPermissionInfo *permPtr = (FSPermissionInfo*)catalogInfo.permissions;
|
||||
permPtr->mode = (UInt16)aPermissions;
|
||||
err = ::FSSetCatalogInfo(&fsRef, kFSCatInfoPermissions, &catalogInfo);
|
||||
return MacErrorMapper(err);
|
||||
CHECK_mBaseRef();
|
||||
|
||||
NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
|
||||
NSNumber* pNumber = [NSNumber numberWithUnsignedInt:aPermissions];
|
||||
NSDictionary* fileAttributes = [NSDictionary dictionaryWithObject:pNumber forKey:NSFilePosixPermissions];
|
||||
// changeFileAttributes:atPath: follows symbolic links though the documentation doesn't mention it
|
||||
BOOL success = [[NSFileManager defaultManager] changeFileAttributes:fileAttributes atPath:[(NSURL*)mBaseRef path]];
|
||||
[ap release];
|
||||
return (success ? NS_OK : NS_ERROR_FAILURE);
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
@ -932,7 +933,7 @@ NS_IMETHODIMP nsLocalFile::SetFileSize(PRInt64 aFileSize)
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
SInt16 refNum;
|
||||
FSIORefNum refNum;
|
||||
OSErr err = ::FSOpenFork(&fsRef, 0, nsnull, fsWrPerm, &refNum);
|
||||
if (err != noErr)
|
||||
return MacErrorMapper(err);
|
||||
|
@ -1731,22 +1732,6 @@ NS_IMETHODIMP nsLocalFile::InitWithFSRef(const FSRef *aFSRef)
|
|||
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_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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
nsLocalFile* file = new nsLocalFile();
|
||||
|
|
|
@ -59,16 +59,16 @@ public:
|
|||
nsXPTType(const XPTTypeDescriptorPrefix& prefix)
|
||||
{*(XPTTypeDescriptorPrefix*)this = prefix;}
|
||||
|
||||
nsXPTType(const uint8& prefix)
|
||||
{*(uint8*)this = prefix;}
|
||||
nsXPTType(const PRUint8& prefix)
|
||||
{*(PRUint8*)this = prefix;}
|
||||
|
||||
nsXPTType& operator=(uint8 val)
|
||||
nsXPTType& operator=(PRUint8 val)
|
||||
{flags = val; return *this;}
|
||||
|
||||
nsXPTType& operator=(const nsXPTType& other)
|
||||
{flags = other.flags; return *this;}
|
||||
|
||||
operator uint8() const
|
||||
operator PRUint8() const
|
||||
{return flags;}
|
||||
|
||||
PRBool IsPointer() const
|
||||
|
@ -111,8 +111,8 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
uint8 TagPart() const
|
||||
{return (uint8) (flags & XPT_TDP_TAGMASK);}
|
||||
PRUint8 TagPart() const
|
||||
{return (PRUint8) (flags & XPT_TDP_TAGMASK);}
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -182,9 +182,9 @@ public:
|
|||
PRBool IsConstructor() const {return 0 != (XPT_MD_IS_CTOR(flags) );}
|
||||
PRBool IsHidden() const {return 0 != (XPT_MD_IS_HIDDEN(flags) );}
|
||||
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 */
|
||||
const nsXPTParamInfo GetParam(uint8 idx) const
|
||||
const nsXPTParamInfo GetParam(PRUint8 idx) const
|
||||
{
|
||||
NS_PRECONDITION(idx < GetParamCount(),"bad arg");
|
||||
return params[idx];
|
||||
|
|
|
@ -121,14 +121,14 @@ public:
|
|||
// No ctors or dtors so that we can be in a union in xptiInterfaceInfo.
|
||||
// Allow automatic shallow copies.
|
||||
|
||||
uint16 GetFileIndex() const {return mFileIndex;}
|
||||
uint16 GetZipItemIndex() const {return mZipItemIndex;}
|
||||
PRUint16 GetFileIndex() const {return mFileIndex;}
|
||||
PRUint16 GetZipItemIndex() const {return mZipItemIndex;}
|
||||
|
||||
enum {NOT_ZIP = 0xffff};
|
||||
|
||||
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;}
|
||||
|
||||
PRBool Equals(const xptiTypelib& r) const
|
||||
|
@ -136,8 +136,8 @@ public:
|
|||
mZipItemIndex == r.mZipItemIndex;}
|
||||
|
||||
private:
|
||||
uint16 mFileIndex;
|
||||
uint16 mZipItemIndex;
|
||||
PRUint16 mFileIndex;
|
||||
PRUint16 mZipItemIndex;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
@ -448,8 +448,8 @@ public:
|
|||
class xptiInterfaceGuts
|
||||
{
|
||||
public:
|
||||
uint16 mMethodBaseIndex;
|
||||
uint16 mConstantBaseIndex;
|
||||
PRUint16 mMethodBaseIndex;
|
||||
PRUint16 mConstantBaseIndex;
|
||||
xptiInterfaceEntry* mParent;
|
||||
XPTInterfaceDescriptor* mDescriptor;
|
||||
xptiTypelib mTypelib;
|
||||
|
@ -490,35 +490,35 @@ class xptiInfoFlags
|
|||
{
|
||||
enum {STATE_MASK = 3};
|
||||
public:
|
||||
xptiInfoFlags(uint8 n) : mData(n) {}
|
||||
xptiInfoFlags(PRUint8 n) : mData(n) {}
|
||||
xptiInfoFlags(const xptiInfoFlags& r) : mData(r.mData) {}
|
||||
|
||||
static uint8 GetStateMask()
|
||||
{return uint8(STATE_MASK);}
|
||||
static PRUint8 GetStateMask()
|
||||
{return PRUint8(STATE_MASK);}
|
||||
|
||||
void Clear()
|
||||
{mData = 0;}
|
||||
|
||||
uint8 GetData() const
|
||||
PRUint8 GetData() const
|
||||
{return mData;}
|
||||
|
||||
uint8 GetState() const
|
||||
PRUint8 GetState() const
|
||||
{return mData & GetStateMask();}
|
||||
|
||||
void SetState(uint8 state)
|
||||
void SetState(PRUint8 state)
|
||||
{mData &= ~GetStateMask(); mData |= state;}
|
||||
|
||||
void SetFlagBit(uint8 flag, PRBool on)
|
||||
void SetFlagBit(PRUint8 flag, PRBool on)
|
||||
{if(on)
|
||||
mData |= ~GetStateMask() & flag;
|
||||
else
|
||||
mData &= GetStateMask() | ~flag;}
|
||||
|
||||
PRBool GetFlagBit(uint8 flag) const
|
||||
PRBool GetFlagBit(PRUint8 flag) const
|
||||
{return (mData & flag) ? PR_TRUE : PR_FALSE;}
|
||||
|
||||
private:
|
||||
uint8 mData;
|
||||
PRUint8 mData;
|
||||
};
|
||||
|
||||
/****************************************************/
|
||||
|
@ -550,10 +550,10 @@ public:
|
|||
// Additional bit flags...
|
||||
enum {SCRIPTABLE = 4};
|
||||
|
||||
uint8 GetResolveState() const {return mFlags.GetState();}
|
||||
PRUint8 GetResolveState() const {return mFlags.GetState();}
|
||||
|
||||
PRBool IsFullyResolved() const
|
||||
{return GetResolveState() == (uint8) FULLY_RESOLVED;}
|
||||
{return GetResolveState() == (PRUint8) FULLY_RESOLVED;}
|
||||
|
||||
PRBool HasInterfaceRecord() const
|
||||
{int s = (int) GetResolveState();
|
||||
|
@ -579,9 +579,9 @@ public:
|
|||
#endif
|
||||
|
||||
void SetScriptableFlag(PRBool on)
|
||||
{mFlags.SetFlagBit(uint8(SCRIPTABLE),on);}
|
||||
{mFlags.SetFlagBit(PRUint8(SCRIPTABLE),on);}
|
||||
PRBool GetScriptableFlag() const
|
||||
{return mFlags.GetFlagBit(uint8(SCRIPTABLE));}
|
||||
{return mFlags.GetFlagBit(PRUint8(SCRIPTABLE));}
|
||||
|
||||
const nsID* GetTheIID() const {return &mIID;}
|
||||
const char* GetTheName() const {return mName;}
|
||||
|
@ -645,7 +645,7 @@ private:
|
|||
void* operator new(size_t, void* p) CPP_THROW_NEW {return p;}
|
||||
|
||||
void SetResolvedState(int state)
|
||||
{mFlags.SetState(uint8(state));}
|
||||
{mFlags.SetState(PRUint8(state));}
|
||||
|
||||
PRBool Resolve(xptiWorkingSet* aWorkingSet = nsnull);
|
||||
|
||||
|
@ -664,7 +664,7 @@ private:
|
|||
xptiInterfaceEntry** entry);
|
||||
|
||||
nsresult GetTypeInArray(const nsXPTParamInfo* param,
|
||||
uint16 dimension,
|
||||
PRUint16 dimension,
|
||||
const XPTTypeDescriptor** type);
|
||||
|
||||
private:
|
||||
|
|
Загрузка…
Ссылка в новой задаче