[2674] | 1 | /* |
---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
| 3 | * contributor license agreements. See the NOTICE file distributed with |
---|
| 4 | * this work for additional information regarding copyright ownership. |
---|
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
| 6 | * (the "License"); you may not use this file except in compliance with |
---|
| 7 | * the License. You may obtain a copy of the License at |
---|
| 8 | * |
---|
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 10 | * |
---|
| 11 | * Unless required by applicable law or agreed to in writing, software |
---|
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 14 | * See the License for the specific language governing permissions and |
---|
| 15 | * limitations under the License. |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | /* |
---|
| 19 | * $Id: MacOSPlatformUtils.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #pragma once |
---|
| 23 | |
---|
| 24 | #include <cstdlib> |
---|
| 25 | #include <xercesc/util/XercesDefs.hpp> |
---|
| 26 | #include <xercesc/util/PlatformUtils.hpp> |
---|
| 27 | #include <xercesc/util/Platforms/MacOS/MacAbstractFile.hpp> |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | #if defined(__APPLE__) |
---|
| 31 | // Framework includes from ProjectBuilder |
---|
| 32 | #include <CoreServices/CoreServices.h> |
---|
| 33 | #else |
---|
| 34 | // Classic includes otherwise |
---|
| 35 | #include <Files.h> |
---|
| 36 | #endif |
---|
| 37 | |
---|
| 38 | XERCES_CPP_NAMESPACE_BEGIN |
---|
| 39 | |
---|
| 40 | // Notes on our Xerces/Mac paths: |
---|
| 41 | // |
---|
| 42 | // Wherever paths are used in Xerces, this Macintosh port assumes that they'll |
---|
| 43 | // be in "unix" format, or at least as close as you can get to that on the particular |
---|
| 44 | // OS. On classic, this means that a path will be a unix style path, separated by '/' and |
---|
| 45 | // starting with the Mac OS volume name. Since slash is used as the segment separator, |
---|
| 46 | // any slashes that actually exist in the segment name will be converted to colons |
---|
| 47 | // (since colon is the Mac OS path separator and would be illegal in a segment name). |
---|
| 48 | // For Mac OS X, paths are created and parsed using the FSRefMakePath, etc, routines: |
---|
| 49 | // the major difference will be location of the volume name within the path. |
---|
| 50 | // |
---|
| 51 | // The routines below help to create and interpret these pathnames for these cases. |
---|
| 52 | // While the port itself never creates such paths, it does use these same routines to |
---|
| 53 | // parse them. |
---|
| 54 | |
---|
| 55 | // Factory method to create an appropriate concrete object |
---|
| 56 | // descended from XMLMacAbstractFile. |
---|
| 57 | XMLUTIL_EXPORT XMLMacAbstractFile* XMLMakeMacFile(MemoryManager* manager); |
---|
| 58 | |
---|
| 59 | // Convert fom FSRef/FSSpec to a Unicode character string path. |
---|
| 60 | // Note that you'll need to delete [] that string after you're done with it! |
---|
| 61 | XMLUTIL_EXPORT XMLCh* XMLCreateFullPathFromFSRef(const FSRef& startingRef, |
---|
| 62 | MemoryManager* const manager = XMLPlatformUtils::fgArrayMemoryManager); |
---|
| 63 | XMLUTIL_EXPORT XMLCh* XMLCreateFullPathFromFSSpec(const FSSpec& startingSpec, |
---|
| 64 | MemoryManager* const manager = XMLPlatformUtils::fgArrayMemoryManager); |
---|
| 65 | |
---|
| 66 | // Convert from path to FSRef/FSSpec |
---|
| 67 | // You retain ownership of the pathName. |
---|
| 68 | // Note: in the general case, these routines will fail if the specified file |
---|
| 69 | // does not exist when the routine is called. |
---|
| 70 | XMLUTIL_EXPORT bool XMLParsePathToFSRef(const XMLCh* const pathName, FSRef& ref, |
---|
| 71 | MemoryManager* const manager = XMLPlatformUtils::fgArrayMemoryManager); |
---|
| 72 | XMLUTIL_EXPORT bool XMLParsePathToFSSpec(const XMLCh* const pathName, FSSpec& spec, |
---|
| 73 | MemoryManager* const manager = XMLPlatformUtils::fgArrayMemoryManager); |
---|
| 74 | |
---|
| 75 | // These routines copy characters between their representation in the Unicode Converter |
---|
| 76 | // and the representation used by XMLCh. Until a recent change in Xerces, these were |
---|
| 77 | // sometimes different on the Macintosh (with GCC), but XMLCh is now fixed at 16 bits. |
---|
| 78 | // Code utilitizing these routines may be phased out in time, as a conversion is no |
---|
| 79 | // longer necessary. |
---|
| 80 | XMLUTIL_EXPORT XMLCh* |
---|
| 81 | CopyUniCharsToXMLChs(const UniChar* src, XMLCh* dst, std::size_t charCount, std::size_t maxChars); |
---|
| 82 | XMLUTIL_EXPORT UniChar* |
---|
| 83 | CopyXMLChsToUniChars(const XMLCh* src, UniChar* dst, std::size_t charCount, std::size_t maxChars); |
---|
| 84 | |
---|
| 85 | // UTF8/UniChar transcoding utilities |
---|
| 86 | XMLUTIL_EXPORT std::size_t |
---|
| 87 | TranscodeUniCharsToUTF8(const UniChar* src, char* dst, std::size_t srcCnt, std::size_t maxChars); |
---|
| 88 | XMLUTIL_EXPORT std::size_t |
---|
| 89 | TranscodeUTF8ToUniChars(const char* src, UniChar* dst, std::size_t maxChars); |
---|
| 90 | |
---|
| 91 | // Size of our statically allocated path buffers |
---|
| 92 | const std::size_t kMaxMacStaticPathChars = 512; |
---|
| 93 | |
---|
| 94 | // Global variables set in platformInit() |
---|
| 95 | extern bool gFileSystemCompatible; |
---|
| 96 | extern bool gMacOSXOrBetter; |
---|
| 97 | extern bool gHasFSSpecAPIs; |
---|
| 98 | extern bool gHasFS2TBAPIs; |
---|
| 99 | extern bool gHasHFSPlusAPIs; |
---|
| 100 | extern bool gHasFSPathAPIs; |
---|
| 101 | extern bool gPathAPIsUsePosixPaths; |
---|
| 102 | extern bool gHasMPAPIs; |
---|
| 103 | extern bool gUsePosixFiles; |
---|
| 104 | |
---|
| 105 | XERCES_CPP_NAMESPACE_END |
---|
| 106 | |
---|