[971] | 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 | * $Log: GzBinFileInputStream.cpp,v $
|
---|
| 19 | * Revision 1.5 2004/09/08 13:56:21 peiyongz
|
---|
| 20 | * Apache License Version 2.0
|
---|
| 21 | *
|
---|
| 22 | * Revision 1.4 2003/12/17 13:58:02 cargilld
|
---|
| 23 | * Platform update for memory management so that the static memory manager (one
|
---|
| 24 | * used to call Initialize) is only for static data.
|
---|
| 25 | *
|
---|
| 26 | * Revision 1.3 2003/05/16 03:11:22 knoaman
|
---|
| 27 | * Partial implementation of the configurable memory manager.
|
---|
| 28 | *
|
---|
| 29 | * Revision 1.2 2002/11/04 15:22:03 tng
|
---|
| 30 | * C++ Namespace Support.
|
---|
| 31 | *
|
---|
| 32 | * Revision 1.1.1.1 2002/02/01 22:22:09 peiyongz
|
---|
| 33 | * sane_include
|
---|
| 34 | *
|
---|
| 35 | * Revision 1.3 2000/03/02 19:54:38 roddey
|
---|
| 36 | * This checkin includes many changes done while waiting for the
|
---|
| 37 | * 1.1.0 code to be finished. I can't list them all here, but a list is
|
---|
| 38 | * available elsewhere.
|
---|
| 39 | *
|
---|
| 40 | * Revision 1.2 2000/02/06 07:48:01 rahulj
|
---|
| 41 | * Year 2K copyright swat.
|
---|
| 42 | *
|
---|
| 43 | * Revision 1.1.1.1 1999/11/09 01:03:59 twl
|
---|
| 44 | * Initial checkin
|
---|
| 45 | *
|
---|
| 46 | * Revision 1.4 1999/11/08 20:56:55 droddey
|
---|
| 47 | * If the main xml entity does not exist, we need to get the error handling for that
|
---|
| 48 | * inside the main XMLScanner::scanDocument() try block so that it gets reported
|
---|
| 49 | * in the normal way. We have to add a little extra safety code because, when this
|
---|
| 50 | * happens, there is no reader on the reader stack to get position ino from.
|
---|
| 51 | *
|
---|
| 52 | * Revision 1.3 1999/11/08 20:45:03 rahul
|
---|
| 53 | * Swat for adding in Product name and CVS comment log variable.
|
---|
| 54 | *
|
---|
| 55 | */
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 | // ---------------------------------------------------------------------------
|
---|
| 59 | // Includes
|
---|
| 60 | // ---------------------------------------------------------------------------
|
---|
| 61 | #include <xercesc/util/BinFileInputStream.hpp>
|
---|
| 62 | #include <xercesc/util/Janitor.hpp>
|
---|
| 63 | #include <xercesc/util/PlatformUtils.hpp>
|
---|
| 64 | #include <xercesc/util/XMLExceptMsgs.hpp>
|
---|
| 65 | #include <xercesc/util/XMLString.hpp>
|
---|
| 66 |
|
---|
| 67 | #include "GzBinFileInputStream.h"
|
---|
[975] | 68 | #include "common.h"
|
---|
[971] | 69 |
|
---|
| 70 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
| 71 |
|
---|
| 72 | // ---------------------------------------------------------------------------
|
---|
| 73 | // GzBinFileInputStream: Constructors and Destructor
|
---|
| 74 | // ---------------------------------------------------------------------------
|
---|
| 75 | GzBinFileInputStream::GzBinFileInputStream(const XMLCh* const fileName
|
---|
| 76 | , MemoryManager* const manager) :
|
---|
[975] | 77 | //fSource(0) ,
|
---|
| 78 | fMemoryManager(manager),
|
---|
| 79 | mCurrentPos(0)
|
---|
[971] | 80 | {
|
---|
| 81 | // Try to open the file
|
---|
| 82 | char *myFileName = XMLString::transcode(fileName);
|
---|
[1264] | 83 | //fSource = XMLPlatformUtils::openFile(fileName, manager);
|
---|
| 84 |
|
---|
[971] | 85 | mStream.open(myFileName);
|
---|
[1001] | 86 |
|
---|
| 87 | delete [] myFileName;
|
---|
[971] | 88 | }
|
---|
| 89 |
|
---|
| 90 | GzBinFileInputStream::GzBinFileInputStream(const char* const fileName,
|
---|
| 91 | MemoryManager* const manager) :
|
---|
[975] | 92 | fMemoryManager(manager),
|
---|
| 93 | mCurrentPos(0)
|
---|
[971] | 94 | {
|
---|
| 95 | // Try to open the file
|
---|
| 96 | mStream.open(fileName);
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 | GzBinFileInputStream::~GzBinFileInputStream()
|
---|
| 101 | {
|
---|
| 102 | mStream.close();
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 |
|
---|
| 106 | // ---------------------------------------------------------------------------
|
---|
| 107 | // GzBinFileInputStream: Getter methods
|
---|
| 108 | // ---------------------------------------------------------------------------
|
---|
| 109 | unsigned int GzBinFileInputStream::getSize() const
|
---|
| 110 | {
|
---|
| 111 | // todo
|
---|
| 112 | return 0;
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 |
|
---|
| 116 | // ---------------------------------------------------------------------------
|
---|
| 117 | // GzBinFileInputStream: Stream management methods
|
---|
| 118 | // ---------------------------------------------------------------------------
|
---|
| 119 | void GzBinFileInputStream::reset()
|
---|
| 120 | {
|
---|
| 121 | // todo
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 |
|
---|
| 125 | // ---------------------------------------------------------------------------
|
---|
| 126 | // GzBinFileInputStream: Implementation of the input stream interface
|
---|
| 127 | // ---------------------------------------------------------------------------
|
---|
| 128 | unsigned int GzBinFileInputStream::curPos() const
|
---|
| 129 | {
|
---|
[975] | 130 | //return XMLPlatformUtils::curFilePos(fSource, fMemoryManager);
|
---|
| 131 | return mCurrentPos;
|
---|
[971] | 132 | }
|
---|
| 133 |
|
---|
[975] | 134 | unsigned int GzBinFileInputStream::readBytes(XMLByte* const toFill,
|
---|
| 135 | const unsigned int maxToRead)
|
---|
[971] | 136 | {
|
---|
| 137 | //
|
---|
| 138 | // Read up to the maximum bytes requested. We return the number
|
---|
| 139 | // actually read.
|
---|
| 140 | //
|
---|
[975] | 141 | //unsigned int result = XMLPlatformUtils::readFileBuffer(fSource, maxToRead, toFill, fMemoryManager);
|
---|
| 142 | mStream.read((char *)toFill, maxToRead);
|
---|
[1264] | 143 | //cout << "\n\n tofill: " << toFill << endl << endl;
|
---|
| 144 |
|
---|
[975] | 145 | unsigned int result = mStream.gcount();
|
---|
| 146 | mCurrentPos = mStream.tellg();
|
---|
| 147 |
|
---|
| 148 | return result;
|
---|
[971] | 149 | }
|
---|
| 150 |
|
---|
| 151 | XERCES_CPP_NAMESPACE_END
|
---|