mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
remove XP_MAC from xpcom. b=281889 r=bsmedberg
This commit is contained in:
parent
8cef1476cf
commit
f94613b36d
@ -44,7 +44,7 @@
|
||||
#include "nscore.h"
|
||||
#include "nsILocalFile.h"
|
||||
|
||||
#if defined(XP_MAC) || defined(XP_MACOSX)
|
||||
#ifdef XP_MACOSX
|
||||
#include <Types.h>
|
||||
#include "nsILocalFileMac.h"
|
||||
#include "prenv.h"
|
||||
@ -130,7 +130,7 @@ enum SystemDirectories {
|
||||
nsresult
|
||||
GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
|
||||
nsILocalFile** aFile);
|
||||
#if defined(XP_MACOSX)
|
||||
#ifdef XP_MACOSX
|
||||
nsresult
|
||||
GetOSXFolderType(short aDomain, OSType aFolderType, nsILocalFile **localFile);
|
||||
#endif
|
||||
|
@ -48,7 +48,7 @@
|
||||
#include "prenv.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
#if defined(XP_MAC) || defined(XP_MACOSX)
|
||||
#if defined(XP_MACOSX)
|
||||
#include <Folders.h>
|
||||
#include <Script.h>
|
||||
#include <Processes.h>
|
||||
@ -75,7 +75,7 @@
|
||||
// WARNING: These hard coded names need to go away. They need to
|
||||
// come from localizable resources
|
||||
|
||||
#if defined(XP_MAC) || defined(XP_MACOSX)
|
||||
#if defined(XP_MACOSX)
|
||||
#define APP_REGISTRY_NAME NS_LITERAL_CSTRING("Application Registry")
|
||||
#define ESSENTIAL_FILES NS_LITERAL_CSTRING("Essential Files")
|
||||
#elif defined(XP_WIN) || defined(XP_OS2)
|
||||
@ -85,7 +85,7 @@
|
||||
#endif
|
||||
|
||||
// define default product directory
|
||||
#if defined (XP_MAC) || defined (WINCE)
|
||||
#ifdef WINCE
|
||||
#define DEFAULT_PRODUCT_DIR NS_LITERAL_CSTRING("Mozilla")
|
||||
#else
|
||||
#define DEFAULT_PRODUCT_DIR NS_LITERAL_CSTRING(MOZ_USER_DIR)
|
||||
@ -95,21 +95,12 @@
|
||||
#define NS_ENV_PLUGINS_DIR "EnvPlugins" // env var MOZ_PLUGIN_PATH
|
||||
#define NS_USER_PLUGINS_DIR "UserPlugins"
|
||||
|
||||
#if defined(XP_MAC) || defined(XP_MACOSX)
|
||||
#ifdef XP_MACOSX
|
||||
#define NS_MACOSX_USER_PLUGIN_DIR "OSXUserPlugins"
|
||||
#define NS_MACOSX_LOCAL_PLUGIN_DIR "OSXLocalPlugins"
|
||||
#define NS_MAC_CLASSIC_PLUGIN_DIR "MacSysPlugins"
|
||||
#endif
|
||||
|
||||
#if defined(XP_MAC)
|
||||
#define DEFAULTS_DIR_NAME NS_LITERAL_CSTRING("Defaults")
|
||||
#define DEFAULTS_PREF_DIR_NAME NS_LITERAL_CSTRING("Pref")
|
||||
#define DEFAULTS_PROFILE_DIR_NAME NS_LITERAL_CSTRING("Profile")
|
||||
#define RES_DIR_NAME NS_LITERAL_CSTRING("Res")
|
||||
#define CHROME_DIR_NAME NS_LITERAL_CSTRING("Chrome")
|
||||
#define PLUGINS_DIR_NAME NS_LITERAL_CSTRING("Plug-ins")
|
||||
#define SEARCH_DIR_NAME NS_LITERAL_CSTRING("Search Plugins")
|
||||
#else
|
||||
#define DEFAULTS_DIR_NAME NS_LITERAL_CSTRING("defaults")
|
||||
#define DEFAULTS_PREF_DIR_NAME NS_LITERAL_CSTRING("pref")
|
||||
#define DEFAULTS_PROFILE_DIR_NAME NS_LITERAL_CSTRING("profile")
|
||||
@ -117,7 +108,6 @@
|
||||
#define CHROME_DIR_NAME NS_LITERAL_CSTRING("chrome")
|
||||
#define PLUGINS_DIR_NAME NS_LITERAL_CSTRING("plugins")
|
||||
#define SEARCH_DIR_NAME NS_LITERAL_CSTRING("searchplugins")
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
// nsAppFileLocationProvider::Constructor/Destructor
|
||||
@ -147,7 +137,7 @@ nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistent, nsIFile
|
||||
*_retval = nsnull;
|
||||
*persistent = PR_TRUE;
|
||||
|
||||
#if defined (XP_MAC) || defined(XP_MACOSX)
|
||||
#ifdef XP_MACOSX
|
||||
short foundVRefNum;
|
||||
long foundDirID;
|
||||
FSSpec fileSpec;
|
||||
@ -215,7 +205,7 @@ nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistent, nsIFile
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME);
|
||||
}
|
||||
#if defined(XP_MAC) || defined(XP_MACOSX)
|
||||
#ifdef XP_MACOSX
|
||||
else if (nsCRT::strcmp(prop, NS_MACOSX_USER_PLUGIN_DIR) == 0)
|
||||
{
|
||||
if (!(::FindFolder(kUserDomain,
|
||||
@ -282,11 +272,6 @@ nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistent, nsIFile
|
||||
// This is cloned so that embeddors will have a hook to override
|
||||
// with their own cleanup dir. See bugzilla bug #105087
|
||||
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
|
||||
#ifdef XP_MAC
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = localFile->AppendNative(ESSENTIAL_FILES);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
if (localFile && NS_SUCCEEDED(rv))
|
||||
@ -349,17 +334,7 @@ NS_METHOD nsAppFileLocationProvider::GetProductDirectory(nsILocalFile **aLocalFi
|
||||
PRBool exists;
|
||||
nsCOMPtr<nsILocalFile> localDir;
|
||||
|
||||
#if defined(XP_MAC)
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
OSErr err;
|
||||
long response;
|
||||
err = ::Gestalt(gestaltSystemVersion, &response);
|
||||
const char *prop = (!err && response >= 0x00001000) ? NS_MAC_USER_LIB_DIR : NS_MAC_DOCUMENTS_DIR;
|
||||
rv = directoryService->Get(prop, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#elif defined(XP_MACOSX)
|
||||
#if defined(XP_MACOSX)
|
||||
FSRef fsRef;
|
||||
OSType folderType = aLocal ? kCachedDataFolderType : kDomainLibraryFolderType;
|
||||
OSErr err = ::FSFindFolder(kUserDomain, folderType, kCreateFolder, &fsRef);
|
||||
@ -450,7 +425,7 @@ NS_METHOD nsAppFileLocationProvider::GetDefaultUserProfileRoot(nsILocalFile **aL
|
||||
rv = GetProductDirectory(getter_AddRefs(localDir), aLocal);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
#if defined(XP_MAC) || defined(XP_MACOSX) || defined(XP_OS2) || defined(XP_WIN)
|
||||
#if defined(XP_MACOSX) || defined(XP_OS2) || defined(XP_WIN)
|
||||
// These 3 platforms share this part of the path - do them as one
|
||||
rv = localDir->AppendRelativeNativePath(NS_LITERAL_CSTRING("Profiles"));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
@ -603,7 +578,7 @@ nsAppFileLocationProvider::GetFiles(const char *prop, nsISimpleEnumerator **_ret
|
||||
|
||||
if (!nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR_LIST))
|
||||
{
|
||||
#if defined(XP_MAC) || defined(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* os9Keys[] = { NS_APP_PLUGINS_DIR, NS_MAC_CLASSIC_PLUGIN_DIR, nsnull };
|
||||
static const char** keys;
|
||||
|
@ -50,18 +50,12 @@
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsIStringEnumerator.h"
|
||||
|
||||
#if defined(XP_MAC)
|
||||
#include <Folders.h>
|
||||
#include <Files.h>
|
||||
#include <Memory.h>
|
||||
#include <Processes.h>
|
||||
#include <Gestalt.h>
|
||||
#elif defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
#include <windows.h>
|
||||
#include <shlobj.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#elif defined(XP_UNIX) || defined(XP_MACOSX)
|
||||
#elif defined(XP_UNIX)
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/param.h>
|
||||
@ -92,13 +86,8 @@
|
||||
#include "SpecialSystemDirectory.h"
|
||||
#include "nsAppFileLocationProvider.h"
|
||||
|
||||
#if defined(XP_MAC)
|
||||
#define COMPONENT_REGISTRY_NAME NS_LITERAL_CSTRING("Component Registry")
|
||||
#define COMPONENT_DIRECTORY NS_LITERAL_CSTRING("Components")
|
||||
#else
|
||||
#define COMPONENT_REGISTRY_NAME NS_LITERAL_CSTRING("compreg.dat")
|
||||
#define COMPONENT_DIRECTORY NS_LITERAL_CSTRING("components")
|
||||
#endif
|
||||
|
||||
#define XPTI_REGISTRY_NAME NS_LITERAL_CSTRING("xpti.dat")
|
||||
|
||||
@ -106,7 +95,7 @@
|
||||
// For Windows platform, We are choosing Appdata folder as HOME
|
||||
#if defined (XP_WIN)
|
||||
#define HOME_DIR NS_WIN_APPDATA_DIR
|
||||
#elif defined (XP_MAC) || defined (XP_MACOSX)
|
||||
#elif defined (XP_MACOSX)
|
||||
#define HOME_DIR NS_OSX_HOME_DIR
|
||||
#elif defined (XP_UNIX)
|
||||
#define HOME_DIR NS_UNIX_HOME_DIR
|
||||
@ -169,35 +158,6 @@ nsDirectoryService::GetCurrentProcessDirectory(nsILocalFile** aFile)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#elif defined(XP_MAC)
|
||||
// get info for the the current process to determine the directory
|
||||
// its located in
|
||||
OSErr err;
|
||||
ProcessSerialNumber psn = {kNoProcess, kCurrentProcess};
|
||||
ProcessInfoRec pInfo;
|
||||
FSSpec tempSpec;
|
||||
|
||||
// initialize ProcessInfoRec before calling
|
||||
// GetProcessInformation() or die horribly.
|
||||
pInfo.processName = nil;
|
||||
pInfo.processAppSpec = &tempSpec;
|
||||
pInfo.processInfoLength = sizeof(ProcessInfoRec);
|
||||
|
||||
err = GetProcessInformation(&psn, &pInfo);
|
||||
if (!err)
|
||||
{
|
||||
// create an FSSpec from the volume and dirid of the app.
|
||||
FSSpec appFSSpec;
|
||||
::FSMakeFSSpec(pInfo.processAppSpec->vRefNum, pInfo.processAppSpec->parID, 0, &appFSSpec);
|
||||
|
||||
nsCOMPtr<nsILocalFileMac> localFileMac = do_QueryInterface((nsIFile*)localFile);
|
||||
if (localFileMac)
|
||||
{
|
||||
localFileMac->InitWithFSSpec(&appFSSpec);
|
||||
*aFile = localFile;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
#elif defined(XP_MACOSX)
|
||||
// Works even if we're not bundled.
|
||||
CFBundleRef appBundle = CFBundleGetMainBundle();
|
||||
|
@ -234,7 +234,7 @@ interface nsIFile : nsISupports
|
||||
* strings are not guaranteed to be a usable path to pass to
|
||||
* NSPR or the C stdlib. There are problems that affect
|
||||
* platforms on which a path does not fully specify a file
|
||||
* because two volumes can have the same name (e.g., XP_MAC).
|
||||
* because two volumes can have the same name (e.g., mac).
|
||||
* This is solved by holding "private", native data in the
|
||||
* nsIFile implementation. This native data is lost when
|
||||
* you convert to a string.
|
||||
|
@ -74,8 +74,6 @@
|
||||
#include "nsLocalFileWin.h"
|
||||
#elif defined(XP_MACOSX)
|
||||
#include "nsLocalFileOSX.h"
|
||||
#elif defined(XP_MAC)
|
||||
#include "nsLocalFileMac.h"
|
||||
#elif defined(XP_UNIX) || defined(XP_BEOS)
|
||||
#include "nsLocalFileUnix.h"
|
||||
#elif defined(XP_OS2)
|
||||
|
@ -61,7 +61,7 @@ void NS_ShutdownLocalFile()
|
||||
nsLocalFile::GlobalShutdown();
|
||||
}
|
||||
|
||||
#if !defined(XP_MAC) && !defined(XP_MACOSX) && !defined(XP_WIN)
|
||||
#if !defined(XP_MACOSX) && !defined(XP_WIN)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::InitWithFile(nsILocalFile *aFile)
|
||||
{
|
||||
@ -75,13 +75,8 @@ nsLocalFile::InitWithFile(nsILocalFile *aFile)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(XP_MAC)
|
||||
#define kMaxFilenameLength 31
|
||||
#define kMaxExtensionLength 10
|
||||
#else
|
||||
#define kMaxFilenameLength 255
|
||||
#define kMaxExtensionLength 100
|
||||
#endif
|
||||
// requirement: kMaxExtensionLength < kMaxFilenameLength - 4
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -125,9 +120,7 @@ nsLocalFile::CreateUnique(PRUint32 type, PRUint32 attributes)
|
||||
return NS_ERROR_FILE_TOO_BIG;
|
||||
}
|
||||
|
||||
#if defined(XP_MAC)
|
||||
static const PRUnichar kPathSeparatorChar = ':';
|
||||
#elif defined(XP_WIN) || defined(XP_OS2)
|
||||
#if defined(XP_WIN) || defined(XP_OS2)
|
||||
static const PRUnichar kPathSeparatorChar = '\\';
|
||||
#elif defined(XP_UNIX) || defined(XP_BEOS)
|
||||
static const PRUnichar kPathSeparatorChar = '/';
|
||||
@ -135,11 +128,6 @@ static const PRUnichar kPathSeparatorChar = '/';
|
||||
#error Need to define file path separator for your platform
|
||||
#endif
|
||||
|
||||
#if defined(XP_MAC)
|
||||
static const char kSlashStr[] = "/";
|
||||
static const char kESCSlashStr[] = "%2F";
|
||||
#endif
|
||||
|
||||
static PRInt32 SplitPath(PRUnichar *path, PRUnichar **nodeArray, PRInt32 arrayLen)
|
||||
{
|
||||
if (*path == 0)
|
||||
@ -212,9 +200,6 @@ nsLocalFile::GetRelativeDescriptor(nsILocalFile *fromFile, nsACString& _retval)
|
||||
_retval.AppendLiteral("../");
|
||||
for (nodeIndex = branchIndex; nodeIndex < thisNodeCnt; nodeIndex++) {
|
||||
NS_ConvertUTF16toUTF8 nodeStr(thisNodes[nodeIndex]);
|
||||
#ifdef XP_MAC
|
||||
nodeStr.ReplaceSubstring(kSlashStr, kESCSlashStr);
|
||||
#endif
|
||||
_retval.Append(nodeStr);
|
||||
if (nodeIndex + 1 < thisNodeCnt)
|
||||
_retval.Append('/');
|
||||
@ -261,13 +246,7 @@ nsLocalFile::SetRelativeDescriptor(nsILocalFile *fromFile, const nsACString& rel
|
||||
nodeBegin = nodeEnd = pos;
|
||||
while (nodeEnd != strEnd) {
|
||||
FindCharInReadable('/', nodeEnd, strEnd);
|
||||
#ifdef XP_MAC
|
||||
nsCAutoString nodeString(Substring(nodeBegin, nodeEnd));
|
||||
nodeString.ReplaceSubstring(kESCSlashStr, kSlashStr);
|
||||
targetFile->Append(NS_ConvertUTF8toUTF16(nodeString));
|
||||
#else
|
||||
targetFile->Append(NS_ConvertUTF8toUTF16(Substring(nodeBegin, nodeEnd)));
|
||||
#endif
|
||||
if (nodeEnd != strEnd) // If there's more left in the string, inc over the '/' nodeEnd is on.
|
||||
++nodeEnd;
|
||||
nodeBegin = nodeEnd;
|
||||
|
@ -1131,195 +1131,6 @@ NS_ShutdownNativeCharsetUtils()
|
||||
::UniFreeUconvObject(UnicodeConverter);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// XP_MAC
|
||||
//-----------------------------------------------------------------------------
|
||||
#elif defined(XP_MAC)
|
||||
|
||||
#include <UnicodeConverter.h>
|
||||
#include <TextCommon.h>
|
||||
#include <Script.h>
|
||||
#include <MacErrors.h>
|
||||
#include "nsAString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
class nsFSStringConversionMac {
|
||||
public:
|
||||
static nsresult UCSToFS(const nsAString& aIn, nsACString& aOut);
|
||||
static nsresult FSToUCS(const nsACString& ain, nsAString& aOut);
|
||||
|
||||
static void CleanUp();
|
||||
|
||||
private:
|
||||
static TextEncoding GetSystemEncoding();
|
||||
static nsresult PrepareEncoder();
|
||||
static nsresult PrepareDecoder();
|
||||
|
||||
static UnicodeToTextInfo sEncoderInfo;
|
||||
static TextToUnicodeInfo sDecoderInfo;
|
||||
};
|
||||
|
||||
UnicodeToTextInfo nsFSStringConversionMac::sEncoderInfo = nsnull;
|
||||
TextToUnicodeInfo nsFSStringConversionMac::sDecoderInfo = nsnull;
|
||||
|
||||
nsresult nsFSStringConversionMac::UCSToFS(const nsAString& aIn, nsACString& aOut)
|
||||
{
|
||||
nsresult rv = PrepareEncoder();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
OSStatus err = noErr;
|
||||
char stackBuffer[512];
|
||||
|
||||
aOut.Truncate();
|
||||
|
||||
// for each chunk of |aIn|...
|
||||
nsReadingIterator<PRUnichar> iter;
|
||||
aIn.BeginReading(iter);
|
||||
|
||||
PRUint32 fragmentLength = PRUint32(iter.size_forward());
|
||||
UInt32 bytesLeft = fragmentLength * sizeof(UniChar);
|
||||
|
||||
do {
|
||||
UInt32 bytesRead = 0, bytesWritten = 0;
|
||||
err = ::ConvertFromUnicodeToText(sEncoderInfo,
|
||||
bytesLeft,
|
||||
(const UniChar*)iter.get(),
|
||||
kUnicodeUseFallbacksMask | kUnicodeLooseMappingsMask,
|
||||
0, nsnull, nsnull, nsnull,
|
||||
sizeof(stackBuffer),
|
||||
&bytesRead,
|
||||
&bytesWritten,
|
||||
stackBuffer);
|
||||
if (err == kTECUsedFallbacksStatus)
|
||||
err = noErr;
|
||||
else if (err == kTECOutputBufferFullStatus) {
|
||||
bytesLeft -= bytesRead;
|
||||
iter.advance(bytesRead / sizeof(UniChar));
|
||||
}
|
||||
aOut.Append(stackBuffer, bytesWritten);
|
||||
}
|
||||
while (err == kTECOutputBufferFullStatus);
|
||||
|
||||
return (err == noErr) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult nsFSStringConversionMac::FSToUCS(const nsACString& aIn, nsAString& aOut)
|
||||
{
|
||||
nsresult rv = PrepareDecoder();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
OSStatus err = noErr;
|
||||
UniChar stackBuffer[512];
|
||||
|
||||
aOut.Truncate(0);
|
||||
|
||||
// for each chunk of |aIn|...
|
||||
nsReadingIterator<char> iter;
|
||||
aIn.BeginReading(iter);
|
||||
|
||||
PRUint32 fragmentLength = PRUint32(iter.size_forward());
|
||||
UInt32 bytesLeft = fragmentLength;
|
||||
|
||||
do {
|
||||
UInt32 bytesRead = 0, bytesWritten = 0;
|
||||
err = ::ConvertFromTextToUnicode(sDecoderInfo,
|
||||
bytesLeft,
|
||||
iter.get(),
|
||||
kUnicodeUseFallbacksMask | kUnicodeLooseMappingsMask,
|
||||
0, nsnull, nsnull, nsnull,
|
||||
sizeof(stackBuffer),
|
||||
&bytesRead,
|
||||
&bytesWritten,
|
||||
stackBuffer);
|
||||
if (err == kTECUsedFallbacksStatus)
|
||||
err = noErr;
|
||||
else if (err == kTECOutputBufferFullStatus) {
|
||||
bytesLeft -= bytesRead;
|
||||
iter.advance(bytesRead);
|
||||
}
|
||||
aOut.Append((PRUnichar *)stackBuffer, bytesWritten / sizeof(PRUnichar));
|
||||
}
|
||||
while (err == kTECOutputBufferFullStatus);
|
||||
|
||||
return (err == noErr) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void nsFSStringConversionMac::CleanUp()
|
||||
{
|
||||
if (sDecoderInfo) {
|
||||
::DisposeTextToUnicodeInfo(&sDecoderInfo);
|
||||
sDecoderInfo = nsnull;
|
||||
}
|
||||
if (sEncoderInfo) {
|
||||
::DisposeUnicodeToTextInfo(&sEncoderInfo);
|
||||
sEncoderInfo = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
TextEncoding nsFSStringConversionMac::GetSystemEncoding()
|
||||
{
|
||||
OSStatus err;
|
||||
TextEncoding theEncoding;
|
||||
|
||||
err = ::UpgradeScriptInfoToTextEncoding(smSystemScript, kTextLanguageDontCare,
|
||||
kTextRegionDontCare, NULL, &theEncoding);
|
||||
|
||||
if (err != noErr)
|
||||
theEncoding = kTextEncodingMacRoman;
|
||||
|
||||
return theEncoding;
|
||||
}
|
||||
|
||||
nsresult nsFSStringConversionMac::PrepareEncoder()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (!sEncoderInfo) {
|
||||
OSStatus err;
|
||||
err = ::CreateUnicodeToTextInfoByEncoding(GetSystemEncoding(), &sEncoderInfo);
|
||||
if (err)
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsFSStringConversionMac::PrepareDecoder()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (!sDecoderInfo) {
|
||||
OSStatus err;
|
||||
err = ::CreateTextToUnicodeInfoByEncoding(GetSystemEncoding(), &sDecoderInfo);
|
||||
if (err)
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_COM nsresult
|
||||
NS_CopyNativeToUnicode(const nsACString &input, nsAString &output)
|
||||
{
|
||||
return nsFSStringConversionMac::FSToUCS(input, output);
|
||||
}
|
||||
|
||||
NS_COM nsresult
|
||||
NS_CopyUnicodeToNative(const nsAString &input, nsACString &output)
|
||||
{
|
||||
return nsFSStringConversionMac::UCSToFS(input, output);
|
||||
}
|
||||
|
||||
void
|
||||
NS_StartupNativeCharsetUtils()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
NS_ShutdownNativeCharsetUtils()
|
||||
{
|
||||
nsFSStringConversionMac::CleanUp();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// default : truncate/zeropad
|
||||
//-----------------------------------------------------------------------------
|
||||
#else
|
||||
|
||||
#include "nsReadableUtils.h"
|
||||
|
@ -71,11 +71,8 @@ static inline char *GetLastSeparator(const char *str, char sep)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
#ifdef XP_MACOSX
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#if defined(XP_MAC) || defined(XP_MACOSX)
|
||||
#include <Aliases.h>
|
||||
#include <TextUtils.h>
|
||||
#endif
|
||||
@ -316,10 +313,8 @@ NS_NAMESPACE nsFileSpecHelpers
|
||||
, kMaxAltDigitLength = 5
|
||||
, kMaxCoreLeafNameLength = (kMaxFilenameLength - (kMaxAltDigitLength + 1))
|
||||
};
|
||||
#if !defined(XP_MAC)
|
||||
NS_NAMESPACE_PROTOTYPE void Canonify(nsSimpleCharString& ioPath, PRBool inMakeDirs);
|
||||
NS_NAMESPACE_PROTOTYPE void MakeAllDirectories(const char* inPath, int mode);
|
||||
#endif
|
||||
#if defined(XP_WIN) || defined(XP_OS2)
|
||||
NS_NAMESPACE_PROTOTYPE void NativeToUnix(nsSimpleCharString& ioPath);
|
||||
NS_NAMESPACE_PROTOTYPE void UnixToNative(nsSimpleCharString& ioPath);
|
||||
@ -416,11 +411,6 @@ char* nsSimpleCharString::GetLeaf(char inSeparator) const
|
||||
return result;
|
||||
} // nsSimpleCharString::GetLeaf
|
||||
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
#if (defined(XP_UNIX) || defined(XP_WIN) || defined(XP_OS2) || defined(XP_BEOS))
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -507,18 +497,11 @@ void nsFileSpecHelpers::MakeAllDirectories(const char* inPath, int mode)
|
||||
|
||||
#endif // XP_UNIX || XP_WIN || XP_OS2 || XP_BEOS
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
#if defined(XP_WIN)
|
||||
#include "nsFileSpecWin.cpp" // Windows-specific implementations
|
||||
#elif defined(XP_MAC)
|
||||
//#include "nsFileSpecMac.cpp" // Macintosh-specific implementations
|
||||
// we include the .cpp file in the project now.
|
||||
#elif defined(XP_BEOS)
|
||||
#include "nsFileSpecBeOS.cpp" // BeOS-specific implementations
|
||||
#elif defined(XP_UNIX) || defined(XP_MACOSX)
|
||||
#elif defined(XP_UNIX)
|
||||
#include "nsFileSpecUnix.cpp" // Unix-specific implementations
|
||||
#elif defined(XP_OS2)
|
||||
#include "nsFileSpecOS2.cpp" // OS/2-specific implementations
|
||||
@ -528,7 +511,6 @@ void nsFileSpecHelpers::MakeAllDirectories(const char* inPath, int mode)
|
||||
// nsFileURL implementation
|
||||
//========================================================================================
|
||||
|
||||
#if !defined(XP_MAC)
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::nsFileURL(const char* inString, PRBool inCreateDirs)
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -544,9 +526,7 @@ nsFileURL::nsFileURL(const char* inString, PRBool inCreateDirs)
|
||||
nsFilePath path(unescapedPath, inCreateDirs);
|
||||
*this = path;
|
||||
} // nsFileURL::nsFileURL
|
||||
#endif
|
||||
|
||||
#if !defined(XP_MAC)
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::nsFileURL(const nsString& inString, PRBool inCreateDirs)
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -564,35 +544,27 @@ nsFileURL::nsFileURL(const nsString& inString, PRBool inCreateDirs)
|
||||
nsFilePath path(unescapedPath, inCreateDirs);
|
||||
*this = path;
|
||||
} // nsFileURL::nsFileURL
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::nsFileURL(const nsFileURL& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mURL(inOther.mURL)
|
||||
#if defined(XP_MAC)
|
||||
, mFileSpec(inOther.GetFileSpec())
|
||||
#endif
|
||||
: mURL(inOther.mURL)
|
||||
{
|
||||
} // nsFileURL::nsFileURL
|
||||
|
||||
#if !defined(XP_MAC)
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::nsFileURL(const nsFilePath& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
*this = inOther;
|
||||
} // nsFileURL::nsFileURL
|
||||
#endif
|
||||
|
||||
#if !defined(XP_MAC)
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::nsFileURL(const nsFileSpec& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
*this = inOther;
|
||||
} // nsFileURL::nsFileURL
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::~nsFileURL()
|
||||
@ -600,7 +572,6 @@ nsFileURL::~nsFileURL()
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined(XP_MAC)
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileURL::operator = (const char* inString)
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -611,7 +582,6 @@ void nsFileURL::operator = (const char* inString)
|
||||
mURL = inString;
|
||||
NS_ASSERTION(strstr(inString, kFileURLPrefix) == inString, "Not a URL!");
|
||||
} // nsFileURL::operator =
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileURL::operator +=(const char* inRelativeUnixPath)
|
||||
@ -620,9 +590,6 @@ void nsFileURL::operator +=(const char* inRelativeUnixPath)
|
||||
char* escapedPath = nsEscape(inRelativeUnixPath, url_Path);
|
||||
mURL += escapedPath;
|
||||
nsCRT::free(escapedPath);
|
||||
#if defined(XP_MAC)
|
||||
mFileSpec += inRelativeUnixPath;
|
||||
#endif
|
||||
} // nsFileURL::operator +=
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -639,12 +606,8 @@ void nsFileURL::operator = (const nsFileURL& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mURL = inOther.mURL;
|
||||
#if defined(XP_MAC)
|
||||
mFileSpec = inOther.GetFileSpec();
|
||||
#endif
|
||||
} // nsFileURL::operator =
|
||||
|
||||
#if !defined(XP_MAC)
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileURL::operator = (const nsFilePath& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -666,9 +629,7 @@ void nsFileURL::operator = (const nsFilePath& inOther)
|
||||
mURL += escapedPath;
|
||||
nsCRT::free(escapedPath);
|
||||
} // nsFileURL::operator =
|
||||
#endif
|
||||
|
||||
#if !defined(XP_MAC)
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileURL::operator = (const nsFileSpec& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -677,11 +638,7 @@ void nsFileURL::operator = (const nsFileSpec& inOther)
|
||||
if (mURL[mURL.Length() - 1] != '/' && inOther.IsDirectory())
|
||||
mURL += "/";
|
||||
} // nsFileURL::operator =
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
//========================================================================================
|
||||
// nsFilePath implementation
|
||||
@ -691,13 +648,9 @@ void nsFileURL::operator = (const nsFileSpec& inOther)
|
||||
nsFilePath::nsFilePath(const nsFilePath& inPath)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mPath(inPath.mPath)
|
||||
#if defined(XP_MAC)
|
||||
, mFileSpec(inPath.mFileSpec)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined(XP_MAC)
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFilePath::nsFilePath(const char* inString, PRBool inCreateDirs)
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -722,9 +675,7 @@ nsFilePath::nsFilePath(const char* inString, PRBool inCreateDirs)
|
||||
nsFileSpecHelpers::NativeToUnix(mPath);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(XP_MAC)
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFilePath::nsFilePath(const nsString& inString, PRBool inCreateDirs)
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -745,9 +696,7 @@ nsFilePath::nsFilePath(const nsString& inString, PRBool inCreateDirs)
|
||||
nsFileSpecHelpers::NativeToUnix(mPath);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(XP_MAC)
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFilePath::nsFilePath(const nsFileURL& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -755,7 +704,6 @@ nsFilePath::nsFilePath(const nsFileURL& inOther)
|
||||
mPath = (const char*)inOther.mURL + kFileURLPrefixLength;
|
||||
mPath.Unescape();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (defined XP_UNIX || defined XP_BEOS)
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -764,7 +712,7 @@ nsFilePath::nsFilePath(const nsFileSpec& inOther)
|
||||
: mPath(inOther.mPath)
|
||||
{
|
||||
}
|
||||
#endif // XP_UNIX
|
||||
#endif // XP_UNIX || XP_BEOS
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFilePath::~nsFilePath()
|
||||
@ -783,7 +731,6 @@ void nsFilePath::operator = (const nsFileSpec& inOther)
|
||||
}
|
||||
#endif // XP_UNIX
|
||||
|
||||
#if !defined(XP_MAC)
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFilePath::operator = (const char* inString)
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -802,25 +749,19 @@ void nsFilePath::operator = (const char* inString)
|
||||
nsFileSpecHelpers::NativeToUnix(mPath);
|
||||
#endif
|
||||
}
|
||||
#endif // XP_MAC
|
||||
|
||||
#if !defined(XP_MAC)
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFilePath::operator = (const nsFileURL& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mPath = (const char*)nsFilePath(inOther);
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFilePath::operator = (const nsFilePath& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mPath = inOther.mPath;
|
||||
#if defined(XP_MAC)
|
||||
mFileSpec = inOther.GetFileSpec();
|
||||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -832,9 +773,6 @@ void nsFilePath::operator +=(const char* inRelativeUnixPath)
|
||||
char* escapedPath = nsEscape(inRelativeUnixPath, url_Path);
|
||||
mPath += escapedPath;
|
||||
nsCRT::free(escapedPath);
|
||||
#if defined(XP_MAC)
|
||||
mFileSpec += inRelativeUnixPath;
|
||||
#endif
|
||||
} // nsFilePath::operator +=
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -849,15 +787,10 @@ nsFilePath nsFilePath::operator +(const char* inRelativeUnixPath) const
|
||||
} // nsFilePath::operator +
|
||||
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
//========================================================================================
|
||||
// nsFileSpec implementation
|
||||
//========================================================================================
|
||||
|
||||
#if !defined(XP_MAC)
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileSpec::nsFileSpec()
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -874,8 +807,6 @@ void nsFileSpec::Clear()
|
||||
mError = NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileSpec::~nsFileSpec()
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -949,7 +880,7 @@ void nsFileSpec::operator = (const nsPersistentFileDescriptor& inDescriptor)
|
||||
nsCAutoString data;
|
||||
inDescriptor.GetData(data);
|
||||
|
||||
#if defined (XP_MAC) || defined(XP_MACOSX)
|
||||
#ifdef XP_MACOSX
|
||||
// Decode descriptor into a Handle (which is actually an AliasHandle)
|
||||
char* decodedData = PL_Base64Decode(data.get(), data.Length(), nsnull);
|
||||
Handle aliasH = nsnull;
|
||||
@ -957,14 +888,7 @@ void nsFileSpec::operator = (const nsPersistentFileDescriptor& inDescriptor)
|
||||
PR_Free(decodedData);
|
||||
if (NS_FAILED(mError))
|
||||
return; // not enough memory?
|
||||
#endif
|
||||
|
||||
#if defined(XP_MAC)
|
||||
Boolean changed;
|
||||
mError = NS_FILE_RESULT(::ResolveAlias(nsnull, (AliasHandle)aliasH, &mSpec, &changed));
|
||||
DisposeHandle((Handle) aliasH);
|
||||
mPath.SetToEmpty();
|
||||
#elif defined(XP_MACOSX)
|
||||
Boolean changed;
|
||||
FSRef fileRef;
|
||||
mError = NS_FILE_RESULT(::FSResolveAlias(nsnull, (AliasHandle)aliasH, &fileRef, &changed));
|
||||
@ -1002,7 +926,7 @@ void nsFileSpec::operator = (const nsFilePath& inPath)
|
||||
mPath = (const char*)inPath;
|
||||
mError = NS_OK;
|
||||
}
|
||||
#endif //XP_UNIX
|
||||
#endif // XP_UNIX || XP_BEOS
|
||||
|
||||
#if (defined(XP_UNIX) || defined(XP_WIN) || defined(XP_OS2) || defined(XP_BEOS))
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -1053,7 +977,7 @@ void nsFileSpec::operator = (const char* inString)
|
||||
nsFileSpecHelpers::Canonify(mPath, PR_FALSE /* XXX? */);
|
||||
mError = NS_OK;
|
||||
}
|
||||
#endif //XP_UNIX,XP_WIN,XP_OS2,XP_BEOS
|
||||
#endif // XP_UNIX,XP_WIN,XP_OS2,XP_BEOS
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileSpec nsFileSpec::operator + (const char* inRelativePath) const
|
||||
@ -1070,13 +994,6 @@ nsFileSpec nsFileSpec::operator + (const char* inRelativePath) const
|
||||
PRBool nsFileSpec::operator == (const nsFileSpec& inOther) const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
|
||||
#if defined(XP_MAC)
|
||||
if ( inOther.mSpec.vRefNum == mSpec.vRefNum &&
|
||||
inOther.mSpec.parID == mSpec.parID &&
|
||||
EqualString(inOther.mSpec.name, mSpec.name, false, true))
|
||||
return PR_TRUE;
|
||||
#else
|
||||
PRBool amEmpty = mPath.IsEmpty();
|
||||
PRBool heEmpty = inOther.mPath.IsEmpty();
|
||||
if (amEmpty) // we're the same if he's empty...
|
||||
@ -1104,19 +1021,17 @@ PRBool nsFileSpec::operator == (const nsFileSpec& inOther) const
|
||||
#else
|
||||
#define DIR_STRCMP strcmp
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
if(str[strLast] == DIR_SEPARATOR)
|
||||
str[strLast] = '\0';
|
||||
|
||||
if(inStr[inLast] == DIR_SEPARATOR)
|
||||
inStr[inLast] = '\0';
|
||||
|
||||
if (DIR_STRCMP(str, inStr ) == 0)
|
||||
if (DIR_STRCMP(str, inStr) == 0)
|
||||
return PR_TRUE;
|
||||
#undef DIR_SEPARATOR
|
||||
#undef DIR_STRCMP
|
||||
#endif
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
@ -1127,7 +1042,6 @@ PRBool nsFileSpec::operator != (const nsFileSpec& inOther) const
|
||||
return (! (*this == inOther) );
|
||||
}
|
||||
|
||||
#if !defined(XP_MAC)
|
||||
//----------------------------------------------------------------------------------------
|
||||
// This is the only automatic conversion to const char*
|
||||
// that is provided, and it allows the
|
||||
@ -1140,7 +1054,6 @@ const char* nsFileSpec::GetCString() const
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Is our spec a child of the provided parent?
|
||||
@ -1178,9 +1091,6 @@ PRBool nsFileSpec::IsChildOf(nsFileSpec &possibleParent)
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
//========================================================================================
|
||||
// class nsPersistentFileDescriptor
|
||||
@ -1211,22 +1121,7 @@ nsPersistentFileDescriptor::nsPersistentFileDescriptor(const nsFileSpec& inSpec)
|
||||
void nsPersistentFileDescriptor::operator = (const nsFileSpec& inSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
#if defined(XP_MAC)
|
||||
if (inSpec.Error())
|
||||
return;
|
||||
AliasHandle aliasH;
|
||||
OSErr err = NewAlias(nil, inSpec.GetFSSpecPtr(), &aliasH);
|
||||
if (err != noErr)
|
||||
return;
|
||||
|
||||
PRUint32 bytes = GetHandleSize((Handle) aliasH);
|
||||
HLock((Handle) aliasH);
|
||||
char* buf = PL_Base64Encode((const char*)*aliasH, bytes, nsnull);
|
||||
DisposeHandle((Handle) aliasH);
|
||||
|
||||
mDescriptorString = buf;
|
||||
PR_Free(buf);
|
||||
#elif defined(XP_MACOSX)
|
||||
#ifdef XP_MACOSX
|
||||
if (inSpec.Error())
|
||||
return;
|
||||
|
||||
@ -1250,7 +1145,7 @@ void nsPersistentFileDescriptor::operator = (const nsFileSpec& inSpec)
|
||||
PR_Free(buf);
|
||||
#else
|
||||
mDescriptorString = inSpec.GetCString();
|
||||
#endif // XP_MAC
|
||||
#endif // XP_MACOSX
|
||||
} // nsPersistentFileDescriptor::operator =
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -1337,19 +1232,8 @@ NS_FileSpecToIFile(nsFileSpec* fileSpec, nsILocalFile* *result)
|
||||
|
||||
if (!file) return NS_ERROR_FAILURE;
|
||||
|
||||
#if defined(XP_MAC)
|
||||
{
|
||||
FSSpec spec = fileSpec->GetFSSpec();
|
||||
nsCOMPtr<nsILocalFileMac> psmAppMacFile = do_QueryInterface(file, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = psmAppMacFile->InitWithFSSpec(&spec);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
file = do_QueryInterface(psmAppMacFile, &rv);
|
||||
}
|
||||
#else
|
||||
// XP_MACOSX: do this for OS X to preserve long filenames
|
||||
rv = file->InitWithNativePath(nsDependentCString(fileSpec->GetNativePathCString()));
|
||||
#endif
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*result = file;
|
||||
|
@ -176,10 +176,7 @@
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#if defined(XP_MAC)
|
||||
#include <Files.h>
|
||||
#include "nsILocalFileMac.h"
|
||||
#elif defined(XP_UNIX) || defined(XP_BEOS)
|
||||
#if defined(XP_UNIX) || defined(XP_BEOS)
|
||||
#include <dirent.h>
|
||||
#elif defined(XP_WIN)
|
||||
|
||||
@ -361,46 +358,11 @@ class NS_COM_OBSOLETE nsFileSpec
|
||||
|
||||
PRBool IsChildOf(nsFileSpec &possibleParent);
|
||||
|
||||
#if defined(XP_MAC)
|
||||
// For Macintosh people, this is meant to be useful in its own right as a C++ version
|
||||
// of the FSSpec struct.
|
||||
nsFileSpec(
|
||||
short vRefNum,
|
||||
long parID,
|
||||
ConstStr255Param name,
|
||||
PRBool resolveAlias = PR_TRUE);
|
||||
|
||||
nsFileSpec(const FSSpec& inSpec, PRBool resolveAlias = PR_TRUE);
|
||||
void operator = (const FSSpec& inSpec);
|
||||
|
||||
operator FSSpec* () { return &mSpec; }
|
||||
operator const FSSpec* const () { return &mSpec; }
|
||||
operator FSSpec& () { return mSpec; }
|
||||
operator const FSSpec& () const { return mSpec; }
|
||||
|
||||
const FSSpec& GetFSSpec() const { return mSpec; }
|
||||
FSSpec& GetFSSpec() { return mSpec; }
|
||||
ConstFSSpecPtr GetFSSpecPtr() const { return &mSpec; }
|
||||
FSSpecPtr GetFSSpecPtr() { return &mSpec; }
|
||||
void MakeAliasSafe();
|
||||
void MakeUnique(ConstStr255Param inSuggestedLeafName);
|
||||
StringPtr GetLeafPName() { return mSpec.name; }
|
||||
ConstStr255Param GetLeafPName() const { return mSpec.name; }
|
||||
|
||||
OSErr GetCatInfo(CInfoPBRec& outInfo) const;
|
||||
|
||||
OSErr SetFileTypeAndCreator(OSType type, OSType creator);
|
||||
OSErr GetFileTypeAndCreator(OSType* type, OSType* creator);
|
||||
|
||||
#endif // end of Macintosh utility methods.
|
||||
|
||||
PRBool Valid() const { return NS_SUCCEEDED(Error()); }
|
||||
nsresult Error() const
|
||||
{
|
||||
#if !defined(XP_MAC)
|
||||
if (mPath.IsEmpty() && NS_SUCCEEDED(mError))
|
||||
((nsFileSpec*)this)->mError = NS_ERROR_NOT_INITIALIZED;
|
||||
#endif
|
||||
return mError;
|
||||
}
|
||||
PRBool Failed() const { return (PRBool)NS_FAILED(Error()); }
|
||||
@ -508,9 +470,7 @@ class NS_COM_OBSOLETE nsFileSpec
|
||||
friend class nsFilePath;
|
||||
friend class nsFileURL;
|
||||
friend class nsDirectoryIterator;
|
||||
#if defined(XP_MAC)
|
||||
FSSpec mSpec;
|
||||
#endif
|
||||
|
||||
nsSimpleCharString mPath;
|
||||
nsresult mError;
|
||||
|
||||
@ -559,11 +519,6 @@ class NS_COM_OBSOLETE nsFileURL
|
||||
const char* GetAsString() const { return (const char*)mURL; }
|
||||
// Not allocated, so don't free it.
|
||||
|
||||
#if defined(XP_MAC)
|
||||
// Accessor to allow quick assignment to a mFileSpec
|
||||
const nsFileSpec& GetFileSpec() const { return mFileSpec; }
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------
|
||||
// Data
|
||||
//--------------------------------------------------
|
||||
@ -571,12 +526,6 @@ class NS_COM_OBSOLETE nsFileURL
|
||||
protected:
|
||||
friend class nsFilePath; // to allow construction of nsFilePath
|
||||
nsSimpleCharString mURL;
|
||||
|
||||
#if defined(XP_MAC)
|
||||
// Since the path on the macintosh does not uniquely specify a file (volumes
|
||||
// can have the same name), stash the secret nsFileSpec, too.
|
||||
nsFileSpec mFileSpec;
|
||||
#endif
|
||||
}; // class nsFileURL
|
||||
|
||||
//========================================================================================
|
||||
@ -612,12 +561,6 @@ class NS_COM_OBSOLETE nsFilePath
|
||||
void operator +=(const char* inRelativeUnixPath);
|
||||
nsFilePath operator +(const char* inRelativeUnixPath) const;
|
||||
|
||||
#if defined(XP_MAC)
|
||||
public:
|
||||
// Accessor to allow quick assignment to a mFileSpec
|
||||
const nsFileSpec& GetFileSpec() const { return mFileSpec; }
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------
|
||||
// Data
|
||||
//--------------------------------------------------
|
||||
@ -625,11 +568,6 @@ class NS_COM_OBSOLETE nsFilePath
|
||||
private:
|
||||
|
||||
nsSimpleCharString mPath;
|
||||
#if defined(XP_MAC)
|
||||
// Since the path on the macintosh does not uniquely specify a file (volumes
|
||||
// can have the same name), stash the secret nsFileSpec, too.
|
||||
nsFileSpec mFileSpec;
|
||||
#endif
|
||||
}; // class nsFilePath
|
||||
|
||||
//========================================================================================
|
||||
@ -699,10 +637,7 @@ class NS_COM_OBSOLETE nsDirectoryIterator
|
||||
public:
|
||||
nsDirectoryIterator( const nsFileSpec& parent,
|
||||
PRBool resoveSymLinks);
|
||||
#if !defined(XP_MAC)
|
||||
// Macintosh currently doesn't allocate, so needn't clean up.
|
||||
virtual ~nsDirectoryIterator();
|
||||
#endif
|
||||
PRBool Exists() const { return mExists; }
|
||||
nsDirectoryIterator& operator ++(); // moves to the next item, if any.
|
||||
nsDirectoryIterator& operator ++(int) { return ++(*this); } // post-increment.
|
||||
@ -711,12 +646,6 @@ class NS_COM_OBSOLETE nsDirectoryIterator
|
||||
operator nsFileSpec&() { return mCurrent; }
|
||||
|
||||
nsFileSpec& Spec() { return mCurrent; }
|
||||
|
||||
private:
|
||||
|
||||
#if defined(XP_MAC)
|
||||
OSErr SetToIndex();
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------
|
||||
// Data
|
||||
@ -731,13 +660,8 @@ class NS_COM_OBSOLETE nsDirectoryIterator
|
||||
#if (defined(XP_UNIX) || defined(XP_BEOS) || defined (XP_WIN) || defined(XP_OS2))
|
||||
nsFileSpec mStarting;
|
||||
#endif
|
||||
|
||||
#if defined(XP_MAC)
|
||||
short mVRefNum;
|
||||
long mParID;
|
||||
short mIndex;
|
||||
short mMaxIndex;
|
||||
#elif defined(XP_UNIX) || defined(XP_BEOS)
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_BEOS)
|
||||
DIR* mDir;
|
||||
#elif defined(XP_WIN) || defined(XP_OS2)
|
||||
PRDir* mDir; // XXX why not use PRDir for Unix too?
|
||||
|
@ -359,8 +359,6 @@ nsOutputStream& nsEndl(nsOutputStream& os)
|
||||
{
|
||||
#if defined(XP_WIN) || defined(XP_OS2)
|
||||
os.write("\r\n", 2);
|
||||
#elif defined (XP_MAC)
|
||||
os.put('\r');
|
||||
#else
|
||||
os.put('\n');
|
||||
#endif
|
||||
|
@ -100,11 +100,7 @@
|
||||
#include "xpcomobsolete.h"
|
||||
#include "nsStringFwd.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include "pprio.h" // To get PR_ImportFile
|
||||
#else
|
||||
#include "prio.h"
|
||||
#endif
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIFileStream.h"
|
||||
@ -136,7 +132,7 @@ class nsIFileSpec;
|
||||
|
||||
#endif // NS_USING_NAMESPACE
|
||||
|
||||
#if !defined(XP_MAC) && !defined(__KCC)
|
||||
#ifndef __KCC
|
||||
// PR_STDOUT and PR_STDIN are fatal on Macintosh. So for console i/o, we must use the std
|
||||
// stream stuff instead. However, we have to require that cout and cin are passed in
|
||||
// to the constructor because in the current build, there is a copy in the base.shlb,
|
||||
|
@ -37,10 +37,6 @@
|
||||
|
||||
/* entry point wrappers. */
|
||||
|
||||
#if defined(XP_MAC)
|
||||
#pragma export on
|
||||
#endif
|
||||
|
||||
#include "xptcprivate.h"
|
||||
|
||||
// This method is never called and is only here so the compiler
|
||||
@ -52,9 +48,6 @@ NS_IMETHODIMP nsXPTCStubBase::QueryInterface(REFNSIID aIID,
|
||||
NS_ASSERTION(0,"wowa! nsXPTCStubBase::QueryInterface called");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#if defined(XP_MAC)
|
||||
#pragma export off
|
||||
#endif
|
||||
|
||||
void
|
||||
xptc_dummy2()
|
||||
|
@ -95,11 +95,6 @@ xpidl_usage(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(XP_MAC) && defined(XPIDL_PLUGIN)
|
||||
#define main xpidl_main
|
||||
int xpidl_main(int argc, char *argv[]);
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
@ -112,11 +107,7 @@ int main(int argc, char *argv[])
|
||||
/* IDL_check_cast_enable(TRUE); */
|
||||
|
||||
inc_head = xpidl_malloc(sizeof *inc);
|
||||
#ifndef XP_MAC
|
||||
inc_head->directory = ".";
|
||||
#else
|
||||
inc_head->directory = "";
|
||||
#endif
|
||||
inc_head->next = NULL;
|
||||
inc_tail = &inc_head->next;
|
||||
|
||||
|
@ -43,10 +43,6 @@
|
||||
#include "xpidl.h"
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include <stat.h>
|
||||
#endif
|
||||
|
||||
static gboolean parsed_empty_file;
|
||||
|
||||
/*
|
||||
@ -66,10 +62,6 @@ xpidl_process_node(TreeState *state)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if defined(XP_MAC) && defined(XPIDL_PLUGIN)
|
||||
extern void mac_warning(const char* warning_message);
|
||||
#endif
|
||||
|
||||
static int
|
||||
msg_callback(int level, int num, int line, const char *file,
|
||||
const char *message)
|
||||
@ -89,11 +81,7 @@ msg_callback(int level, int num, int line, const char *file,
|
||||
file = "<unknown file>";
|
||||
warning_message = g_strdup_printf("%s:%d: %s\n", file, line, message);
|
||||
|
||||
#if defined(XP_MAC) && defined(XPIDL_PLUGIN)
|
||||
mac_warning(warning_message);
|
||||
#else
|
||||
fputs(warning_message, stderr);
|
||||
#endif
|
||||
|
||||
g_free(warning_message);
|
||||
return 1;
|
||||
@ -159,10 +147,6 @@ fopen_from_includes(char **filename, const char *mode,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(XP_MAC) && defined(XPIDL_PLUGIN)
|
||||
extern FILE* mac_fopen(const char* filename, const char *mode);
|
||||
#endif
|
||||
|
||||
static input_data *
|
||||
new_input_data(char **filename, IncludePathEntry *include_path)
|
||||
{
|
||||
@ -171,14 +155,8 @@ new_input_data(char **filename, IncludePathEntry *include_path)
|
||||
char *buffer = NULL;
|
||||
size_t offset = 0;
|
||||
size_t buffer_size;
|
||||
#ifdef XP_MAC
|
||||
size_t i;
|
||||
#endif
|
||||
|
||||
#if defined(XP_MAC) && defined(XPIDL_PLUGIN)
|
||||
/* on Mac, fopen knows how to find files. */
|
||||
inputfile = fopen(*filename, "r");
|
||||
#elif defined(XP_OS2) || defined(XP_WIN32)
|
||||
#if defined(XP_OS2) || defined(XP_WIN32)
|
||||
/*
|
||||
* if filename is fully qualified (starts with driver letter), then
|
||||
* just call fopen(); else, go with fopen_from_includes()
|
||||
@ -193,20 +171,6 @@ new_input_data(char **filename, IncludePathEntry *include_path)
|
||||
|
||||
if (!inputfile)
|
||||
return NULL;
|
||||
|
||||
#ifdef XP_MAC
|
||||
{
|
||||
struct stat input_stat;
|
||||
if (fstat(fileno(inputfile), &input_stat))
|
||||
return NULL;
|
||||
buffer = malloc(input_stat.st_size + 1);
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
offset = fread(buffer, 1, input_stat.st_size, inputfile);
|
||||
if (ferror(inputfile))
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* Rather than try to keep track of many different varieties of state
|
||||
* around the boundaries of a circular buffer, we just read in the entire
|
||||
@ -229,21 +193,9 @@ new_input_data(char **filename, IncludePathEntry *include_path)
|
||||
}
|
||||
offset += just_read;
|
||||
}
|
||||
#endif
|
||||
|
||||
fclose(inputfile);
|
||||
|
||||
#ifdef XP_MAC
|
||||
/*
|
||||
* libIDL doesn't speak '\r' properly - always make sure lines end with
|
||||
* '\n'.
|
||||
*/
|
||||
for (i = 0; i < offset; i++) {
|
||||
if (buffer[i] == '\r')
|
||||
buffer[i] = '\n';
|
||||
}
|
||||
#endif
|
||||
|
||||
new_data = xpidl_malloc(sizeof (struct input_data));
|
||||
new_data->point = new_data->buf = buffer;
|
||||
new_data->max = buffer + offset;
|
||||
|
@ -41,16 +41,10 @@
|
||||
|
||||
#include "xpt_xdr.h"
|
||||
#include <stdio.h>
|
||||
#ifdef XP_MAC
|
||||
#include <stat.h>
|
||||
#include <StandardFile.h>
|
||||
#include "FullPath.h"
|
||||
#else
|
||||
#ifdef XP_OS2_EMX
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "prprf.h"
|
||||
@ -141,16 +135,6 @@ xpt_dump_usage(char *argv[]) {
|
||||
" -v verbose mode\n", argv[0]);
|
||||
}
|
||||
|
||||
#if defined(XP_MAC) && defined(XPIDL_PLUGIN)
|
||||
|
||||
#define main xptdump_main
|
||||
int xptdump_main(int argc, char *argv[]);
|
||||
|
||||
#define get_file_length mac_get_file_length
|
||||
extern size_t mac_get_file_length(const char* filename);
|
||||
|
||||
#else /* !(XP_MAC && XPIDL_PLUGIN) */
|
||||
|
||||
static size_t get_file_length(const char* filename)
|
||||
{
|
||||
struct stat file_stat;
|
||||
@ -161,8 +145,6 @@ static size_t get_file_length(const char* filename)
|
||||
return file_stat.st_size;
|
||||
}
|
||||
|
||||
#endif /* !(XP_MAC && XPIDL_PLUGIN) */
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
|
@ -41,11 +41,7 @@
|
||||
|
||||
#include "xpt_xdr.h"
|
||||
#include <stdio.h>
|
||||
#ifdef XP_MAC
|
||||
#include <stat.h>
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "prlong.h"
|
||||
@ -99,15 +95,6 @@ PRUint16 oldTotalNumberOfInterfaces = 0;
|
||||
PRUint8 major_version = XPT_MAJOR_VERSION;
|
||||
PRUint8 minor_version = XPT_MINOR_VERSION;
|
||||
|
||||
#if defined(XP_MAC) && defined(XPIDL_PLUGIN)
|
||||
|
||||
#define main xptlink_main
|
||||
int xptlink_main(int argc, char *argv[]);
|
||||
extern size_t mac_get_file_length(const char* filename);
|
||||
#define get_file_length mac_get_file_length
|
||||
|
||||
#else
|
||||
|
||||
static size_t get_file_length(const char* filename)
|
||||
{
|
||||
struct stat file_stat;
|
||||
@ -118,8 +105,6 @@ static size_t get_file_length(const char* filename)
|
||||
return file_stat.st_size;
|
||||
}
|
||||
|
||||
#endif /* XP_MAC && XPIDL_PLUGIN */
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user