LCOV - code coverage report
Current view: top level - libreoffice/autodoc/source/tools - filecoll.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 32 50 64.0 %
Date: 2012-12-27 Functions: 7 9 77.8 %
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 <precomp.h>
      21             : #include <tools/filecoll.hxx>
      22             : 
      23             : 
      24             : // NOT FULLY DEFINED SERVICES
      25             : #include <cosv/ploc_dir.hxx>
      26             : 
      27             : #include <stdio.h>
      28             : 
      29             : 
      30           1 : FileCollector::FileCollector( uintt i_nRoughNrOfFiles )
      31             :     // :    aFoundFiles
      32             : {
      33           1 :     if (i_nRoughNrOfFiles > 0)
      34           1 :         aFoundFiles.reserve(i_nRoughNrOfFiles);
      35           1 : }
      36             : 
      37             : uintt
      38         119 : FileCollector::AddFilesFrom( const char *                 i_sRootDir,
      39             :                              const char *                 i_sFilter,
      40             :                              E_SearchMode                 i_eSearchMode )
      41             : {
      42         119 :     uintt nSizeAtStart = aFoundFiles.size();
      43             : 
      44         119 :     if (csv::no_str(i_sFilter) OR csv::no_str(i_sRootDir))
      45             :     {
      46           0 :         Cout() << "Warning: The filter contains no files." <<  Endl();
      47           0 :         return 0;
      48             :     }
      49             : 
      50         119 :     csv::ploc::Directory aDir(i_sRootDir);
      51         119 :     if (NOT aDir.Exists())
      52             :     {
      53           0 :         Cerr() << "Warning: The path for the files to be parsed could not be found:\n"
      54           0 :                << i_sRootDir
      55           0 :                << Endl();
      56           0 :         return 0;
      57             :     }
      58             : 
      59         119 :     Cout() << "." << Flush();
      60         119 :     aDir.GetContainedFiles(aFoundFiles, i_sFilter);
      61             : 
      62         119 :     if (i_eSearchMode == recursive)
      63             :     {
      64         119 :         StreamStr aPath(1020);
      65         119 :         aPath << i_sRootDir << csv::ploc::Delimiter();
      66         119 :         uintt nSubDirStart = aPath.tellp();
      67             : 
      68         119 :         StringVector aSubDirs;
      69         119 :         aDir.GetContainedDirectories(aSubDirs);
      70             : 
      71         711 :         for ( const_iterator iter = aSubDirs.begin();
      72         474 :               iter != aSubDirs.end();
      73             :               ++iter )
      74             :         {
      75         118 :             aPath.seekp(nSubDirStart);
      76         118 :             aPath << (*iter);
      77         118 :             AddFilesFrom( aPath.c_str(), i_sFilter, i_eSearchMode );
      78         119 :         }
      79             :     }
      80             : 
      81         119 :     return aFoundFiles.size() - nSizeAtStart;
      82             : }
      83             : 
      84             : uintt
      85           0 : FileCollector::AddFile( const char * i_sFilePath )
      86             : {
      87           0 :     FILE * pFile = fopen( i_sFilePath, "r" );
      88           0 :     if ( pFile == 0 )
      89             :     {
      90           0 :         Cerr() << "Warning: The path for the file to be parsed could not be found:\n"
      91           0 :                << i_sFilePath
      92           0 :                << Endl();
      93           0 :         return 0;
      94             :     }
      95             : 
      96           0 :     fclose(pFile);
      97           0 :     aFoundFiles.push_back(i_sFilePath);
      98           0 :     return 1;
      99             : }
     100             : 
     101             : void
     102           1 : FileCollector::EraseAll()
     103             : {
     104           1 :     csv::erase_container(aFoundFiles);
     105           1 : }
     106             : 
     107             : FileCollector::const_iterator
     108           1 : FileCollector::Begin() const
     109             : {
     110           1 :     return aFoundFiles.begin();
     111             : }
     112             : 
     113             : FileCollector::const_iterator
     114           1 : FileCollector::End() const
     115             : {
     116           1 :     return aFoundFiles.end();
     117             : }
     118             : 
     119             : uintt
     120           0 : FileCollector::Size() const
     121             : {
     122           0 :     return aFoundFiles.size();
     123           3 : }
     124             : 
     125             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10