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