1ab595ff6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3ab595ff6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4ab595ff6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5ab595ff6SAndrew Rist * distributed with this work for additional information 6ab595ff6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7ab595ff6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8ab595ff6SAndrew Rist * "License"); you may not use this file except in compliance 9ab595ff6SAndrew Rist * with the License. You may obtain a copy of the License at 10ab595ff6SAndrew Rist * 11ab595ff6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12ab595ff6SAndrew Rist * 13ab595ff6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14ab595ff6SAndrew Rist * software distributed under the License is distributed on an 15ab595ff6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16ab595ff6SAndrew Rist * KIND, either express or implied. See the License for the 17ab595ff6SAndrew Rist * specific language governing permissions and limitations 18ab595ff6SAndrew Rist * under the License. 19ab595ff6SAndrew Rist * 20ab595ff6SAndrew Rist *************************************************************/ 21ab595ff6SAndrew Rist 22ab595ff6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "filebuff.hxx" 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <string.h> 27cdf0e10cSrcweir #include <fstream> 28cdf0e10cSrcweir #include <ctype.h> 29cdf0e10cSrcweir 30cdf0e10cSrcweir 31cdf0e10cSrcweir bool LoadXmlFile(Buffer & o_rBuffer,const char * i_sXmlFilePath)32cdf0e10cSrcweirLoadXmlFile( Buffer & o_rBuffer, 33cdf0e10cSrcweir const char * i_sXmlFilePath ) 34cdf0e10cSrcweir { 35cdf0e10cSrcweir std::ifstream aXmlFile; 36cdf0e10cSrcweir 37cdf0e10cSrcweir aXmlFile.open(i_sXmlFilePath, std::ios::in 38cdf0e10cSrcweir #if defined(WNT) || defined(OS2) 39cdf0e10cSrcweir | std::ios::binary 40cdf0e10cSrcweir #endif // WNT 41cdf0e10cSrcweir ); 42cdf0e10cSrcweir 43cdf0e10cSrcweir if (! aXmlFile) 44cdf0e10cSrcweir return false; 45cdf0e10cSrcweir 46cdf0e10cSrcweir // Prepare buffer: 47cdf0e10cSrcweir aXmlFile.seekg(0, std::ios::end); 48cdf0e10cSrcweir unsigned long nBufferSize = (unsigned long) aXmlFile.tellg(); 49cdf0e10cSrcweir o_rBuffer.SetSize(nBufferSize + 1); 50cdf0e10cSrcweir o_rBuffer.Data()[nBufferSize] = '\0'; 51cdf0e10cSrcweir aXmlFile.seekg(0); 52cdf0e10cSrcweir 53cdf0e10cSrcweir // Read file: 54cdf0e10cSrcweir aXmlFile.read(o_rBuffer.Data(), (int) nBufferSize); 55*0c22ca47SHerbert Dürr const bool ret = !aXmlFile.fail(); 56cdf0e10cSrcweir aXmlFile.close(); 57cdf0e10cSrcweir return ret; 58cdf0e10cSrcweir } 59cdf0e10cSrcweir 60