Newer
Older
* Copyright 1999-2000,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id$
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cstdio>
#include <memory>
#include <algorithm>
#if defined(__APPLE__)
// Include from Frameworks Headers under ProjectBuilder
#include <Carbon/Carbon.h>
#else
// Classic include styles
#include <Files.h>
#include <Gestalt.h>
#include <TextUtils.h>
#include <TextEncodingConverter.h>
#include <Multiprocessing.h>
#include <DriverSynchronization.h>
#include <DriverServices.h>
#include <CFString.h>
#include <URLAccess.h>
#endif
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/Janitor.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/RuntimeException.hpp>
#include <xercesc/util/XMLUniDefs.hpp>
#include <xercesc/util/XMLUni.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/Platforms/MacOS/MacOSPlatformUtils.hpp>
#include <xercesc/util/Platforms/MacOS/MacCarbonFile.hpp>
#include <xercesc/util/Platforms/MacOS/MacPosixFile.hpp>
#include <xercesc/util/OutOfMemoryException.hpp>
#if (defined(XML_USE_INMEMORY_MSGLOADER) || defined(XML_USE_INMEM_MESSAGELOADER))
#include <xercesc/util/MsgLoaders/InMemory/InMemMsgLoader.hpp>
#endif
#if defined(XML_USE_ICU_TRANSCODER)
#include <xercesc/util/Transcoders/ICU/ICUTransService.hpp>
#elif (defined(XML_USE_MACOS_UNICODECONVERTER) || defined(XML_USE_NATIVE_TRANSCODER))
#include <xercesc/util/Transcoders/MacOSUnicodeConverter/MacOSUnicodeConverter.hpp>
#endif
James David Berry
committed
// Make up our minds about which netaccessor we'll use
#if (defined(XML_USE_NETACCESSOR_URLACCESSCF) || (defined(XML_USE_NETACCESSOR_NATIVE) && TARGET_API_MAC_CARBON))
#define USE_URLACCESSCF
#elif (defined(XML_USE_NETACCESSOR_URLACCESS) || (defined(XML_USE_NETACCESSOR_NATIVE) && !TARGET_API_MAC_CARBON))
#define USE_URLACCESS
#endif
#if defined(USE_URLACCESSCF)
#include <xercesc/util/NetAccessors/MacOSURLAccessCF/MacOSURLAccessCF.hpp>
#elif defined(USE_URLACCESS)
#include <xercesc/util/NetAccessors/MacOSURLAccess/MacOSURLAccess.hpp>
#elif defined(XML_USE_NETACCESSOR_SOCKET)
#include <xercesc/util/NetAccessors/Socket/SocketNetAccessor.hpp>
//----------------------------------------------------------------------------
// Function Prototypes
//----------------------------------------------------------------------------
XMLCh* ConvertColonToSlash(XMLCh* p, std::size_t charCount);
XMLCh* ConvertSlashToColon(XMLCh* p, std::size_t charCount);
char* ConvertSlashToColon(char* p, std::size_t charCount);
XMLCh* XMLCreateFullPathFromFSRef_X(const FSRef& startingRef, MemoryManager* const manager);
XMLCh* XMLCreateFullPathFromFSRef_Classic(const FSRef& startingRef, MemoryManager* const manager);
XMLCh* XMLCreateFullPathFromFSSpec_Classic(const FSSpec& startingSpec,
MemoryManager* const manager);
bool XMLParsePathToFSRef_X(const XMLCh* const pathName, FSRef& ref, MemoryManager* const manager);
bool XMLParsePathToFSRef_Classic(const XMLCh* const pathName, FSRef& ref, MemoryManager* const manager);
bool XMLParsePathToFSSpec_Classic(const XMLCh* const pathName, FSSpec& spec, MemoryManager* const manager);
//----------------------------------------------------------------------------
// Local Data
//
// gFileSystemCompatible
// This flag indicates whether the file system APIs meet our minimum
// requirements.
//
// gMacOSXOrBetter
// The system version is >= 10.
//
// gHasFSSpecAPIs
// True if the FSSpecAPIs are available. These are required.
//
// gHasF2TBAPIs
// True if the FS supports 2 terrabyte calls. These are required for
// use under Carbon.
//
// gHasHFSPlusAPIs
// True if the FS supports HFSPlus APIs. If this is true, then the
// new Fork calls are used, and all file name and path handling
// uses long unicode names. Note that once a file is opened with
// the fork calls, only fork calls may be used to access it.
//
// gHasFSPathAPIs
James David Berry
committed
// True if the FS supports path creation APIs FSPathMakeRef and
// FSRefMakePath.
//
// gPathAPIsUsePosixPaths
// True if the path creation APIs FSPathMakeRef and FSRefMakePath
// use posix, rather than HFS, style paths. If so, these routines
// are used to support path creation and interpretation.
//
// gHasMPAPIs
// True if the Multiprocessing APIs are available.
//
// gUsePosixFiles
// True if we're using XMLMacPosixFile rather than XMLMacCarbonFile.
James David Berry
committed
//
// gUseGETCWD
// True if we can rely on getcwd to get the current directory path.
//----------------------------------------------------------------------------
James David Berry
committed
bool gMacOSXOrBetter = false;
bool gHasFSSpecAPIs = false;
bool gHasFS2TBAPIs = false;
bool gHasHFSPlusAPIs = false;
bool gHasFSPathAPIs = false;
bool gPathAPIsUsePosixPaths = false;
bool gHasMPAPIs = false;
bool gUsePosixFiles = false;
James David Berry
committed
bool gUseGETCWD = false;
// ---------------------------------------------------------------------------
// XMLPlatformUtils: The panic method
// ---------------------------------------------------------------------------
void
XMLPlatformUtils::panic(const PanicHandler::PanicReasons reason)
James David Berry
committed
if (fgUserPanicHandler)
fgUserPanicHandler->panic(reason);
else
fgDefaultPanicHandler->panic(reason);
}
// ---------------------------------------------------------------------------
// XMLPlatformUtils: File Methods
// ---------------------------------------------------------------------------
unsigned int
David Abram Cargill
committed
XMLPlatformUtils::curFilePos(const FileHandle theFile
, MemoryManager* const manager)
return reinterpret_cast<XMLMacAbstractFile*>(theFile)->currPos();
David Abram Cargill
committed
XMLPlatformUtils::closeFile(const FileHandle theFile
, MemoryManager* const manager)
reinterpret_cast<XMLMacAbstractFile*>(theFile)->close();
James David Berry
committed
delete reinterpret_cast<XMLMacAbstractFile*>(theFile);
David Abram Cargill
committed
XMLPlatformUtils::fileSize(const FileHandle theFile
, MemoryManager* const manager)
return reinterpret_cast<XMLMacAbstractFile*>(theFile)->size();
David Abram Cargill
committed
XMLPlatformUtils::openFile(const char* const fileName
, MemoryManager* const manager)
Loading
Loading full blame...