update credits
[LibreOffice.git] / autodoc / source / tools / filecoll.cxx
blobe232a246d8a877f082cc789f3ac3e4cb7e848f1f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <precomp.h>
21 #include <tools/filecoll.hxx>
24 // NOT FULLY DEFINED SERVICES
25 #include <cosv/ploc_dir.hxx>
27 #include <stdio.h>
30 FileCollector::FileCollector( uintt i_nRoughNrOfFiles )
31 // : aFoundFiles
33 if (i_nRoughNrOfFiles > 0)
34 aFoundFiles.reserve(i_nRoughNrOfFiles);
37 uintt
38 FileCollector::AddFilesFrom( const char * i_sRootDir,
39 const char * i_sFilter,
40 E_SearchMode i_eSearchMode )
42 uintt nSizeAtStart = aFoundFiles.size();
44 if (csv::no_str(i_sFilter) OR csv::no_str(i_sRootDir))
46 Cout() << "Warning: The filter contains no files." << Endl();
47 return 0;
50 csv::ploc::Directory aDir(i_sRootDir);
51 if (NOT aDir.Exists())
53 Cerr() << "Warning: The path for the files to be parsed could not be found:\n"
54 << i_sRootDir
55 << Endl();
56 return 0;
59 Cout() << "." << Flush();
60 aDir.GetContainedFiles(aFoundFiles, i_sFilter);
62 if (i_eSearchMode == recursive)
64 StreamStr aPath(1020);
65 aPath << i_sRootDir << csv::ploc::Delimiter();
66 uintt nSubDirStart = aPath.tellp();
68 StringVector aSubDirs;
69 aDir.GetContainedDirectories(aSubDirs);
71 for ( const_iterator iter = aSubDirs.begin();
72 iter != aSubDirs.end();
73 ++iter )
75 aPath.seekp(nSubDirStart);
76 aPath << (*iter);
77 AddFilesFrom( aPath.c_str(), i_sFilter, i_eSearchMode );
81 return aFoundFiles.size() - nSizeAtStart;
84 uintt
85 FileCollector::AddFile( const char * i_sFilePath )
87 FILE * pFile = fopen( i_sFilePath, "r" );
88 if ( pFile == 0 )
90 Cerr() << "Warning: The path for the file to be parsed could not be found:\n"
91 << i_sFilePath
92 << Endl();
93 return 0;
96 fclose(pFile);
97 aFoundFiles.push_back(i_sFilePath);
98 return 1;
101 void
102 FileCollector::EraseAll()
104 csv::erase_container(aFoundFiles);
107 FileCollector::const_iterator
108 FileCollector::Begin() const
110 return aFoundFiles.begin();
113 FileCollector::const_iterator
114 FileCollector::End() const
116 return aFoundFiles.end();
119 uintt
120 FileCollector::Size() const
122 return aFoundFiles.size();
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */