LCOV - code coverage report
Current view: top level - connectivity/source/drivers/mozab/bootstrap - MNSINIParser.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 40 0.0 %
Date: 2014-04-14 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <MNSINIParser.hxx>
      21             : #include <rtl/byteseq.hxx>
      22             : 
      23           0 : IniParser::IniParser(OUString const & rIniName) throw(com::sun::star::io::IOException )
      24             : {
      25           0 :     OUString iniUrl;
      26           0 :     if (osl_File_E_None != osl_getFileURLFromSystemPath(rIniName.pData, &iniUrl.pData))
      27           0 :         return;
      28             : 
      29             : 
      30             : #if OSL_DEBUG_LEVEL > 0
      31             :     OString sFile = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US);
      32             :     OSL_TRACE(__FILE__" -- parser() - %s\n", sFile.getStr());
      33             : #endif
      34           0 :     oslFileHandle handle=NULL;
      35           0 :     oslFileError fileError = osl_File_E_INVAL;
      36             :     try{
      37           0 :         if (!iniUrl.isEmpty())
      38           0 :             fileError = osl_openFile(iniUrl.pData, &handle, osl_File_OpenFlag_Read);
      39             :     }
      40           0 :     catch(const ::com::sun::star::io::IOException&)
      41             :     {
      42             : #if OSL_DEBUG_LEVEL > 0
      43             :         OString file_tmp = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US);
      44             :         OSL_TRACE( __FILE__" -- couldn't open file: %s", file_tmp.getStr() );
      45             : #endif
      46             :     }
      47             : 
      48           0 :     if (osl_File_E_None == fileError)
      49             :     {
      50           0 :         rtl::ByteSequence seq;
      51           0 :         sal_uInt64 nSize = 0;
      52             : 
      53           0 :         osl_getFileSize(handle, &nSize);
      54           0 :         OUString sectionName(  "no name section" );
      55             :         while (true)
      56             :         {
      57             :             sal_uInt64 nPos;
      58           0 :             if (osl_File_E_None != osl_getFilePos(handle, &nPos) || nPos >= nSize)
      59           0 :                 break;
      60           0 :             if (osl_File_E_None != osl_readLine(handle , (sal_Sequence **) &seq))
      61           0 :                 break;
      62           0 :             OString line( (const sal_Char *) seq.getConstArray(), seq.getLength() );
      63           0 :             sal_Int32 nIndex = line.indexOf('=');
      64           0 :             if (nIndex >= 1)
      65             :             {
      66           0 :                 ini_Section *aSection = &mAllSection[sectionName];
      67           0 :                 struct ini_NameValue nameValue;
      68           0 :                 nameValue.sName = OStringToOUString(
      69           0 :                     line.copy(0,nIndex).trim(), RTL_TEXTENCODING_ASCII_US );
      70           0 :                 nameValue.sValue = OStringToOUString(
      71           0 :                     line.copy(nIndex+1).trim(), RTL_TEXTENCODING_UTF8 );
      72             : 
      73           0 :                 aSection->lList.push_back(nameValue);
      74             : 
      75             :             }
      76             :             else
      77             :             {
      78           0 :                 sal_Int32 nIndexStart = line.indexOf('[');
      79           0 :                 sal_Int32 nIndexEnd = line.indexOf(']');
      80           0 :                 if ( nIndexEnd > nIndexStart && nIndexStart >=0)
      81             :                 {
      82           0 :                     sectionName =  OStringToOUString(
      83           0 :                         line.copy(nIndexStart + 1,nIndexEnd - nIndexStart -1).trim(), RTL_TEXTENCODING_ASCII_US );
      84           0 :                     if (sectionName.isEmpty())
      85           0 :                         sectionName = "no name section";
      86             : 
      87           0 :                     ini_Section *aSection = &mAllSection[sectionName];
      88           0 :                     aSection->sName = sectionName;
      89             :                 }
      90             :             }
      91           0 :         }
      92           0 :         osl_closeFile(handle);
      93           0 :     }
      94             : #if OSL_DEBUG_LEVEL > 0
      95             :     else
      96             :     {
      97             :         OString file_tmp = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US);
      98             :         OSL_TRACE( __FILE__" -- couldn't open file: %s", file_tmp.getStr() );
      99             :     }
     100             : #endif
     101             : }
     102             : 
     103             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10