FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
files.hpp
Go to the documentation of this file.
1 /*
2 Copyright (C) 2013-2014, Siemens AG
3 
4 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.
5 
6 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
7 
8 You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
9 */
10 
11 #ifndef FILES_HPP_
12 #define FILES_HPP_
13 
14 #include <string>
15 #include <glib.h>
16 
22 namespace fo
23 {
24 
29  class File
30  {
31  public:
32  File(unsigned long id, const char* fileName);
33  File(unsigned long id, std::string const& fileName);
34 
35  unsigned long getId() const;
36  std::string getContent(const unsigned long int maximumBytes = 1 << 20) const;
37  const std::string& getFileName() const;
38  bool isReadable() const;
39  private:
40  unsigned long id;
41  std::string fileName;
42  };
43 
44  std::string getStringFromFile(const char* filename, const unsigned long int maximumBytes = 1 << 20);
45  std::string getStringFromFile(std::string const& filename, const unsigned long int maximumBytes = 1 << 20);
46 }
47 
48 #endif /* FILES_HPP_ */
unsigned long id
ID of the file.
Definition: files.hpp:40
std::string getStringFromFile(const char *filename, const unsigned long int maximumBytes)
Reads the content of a file and return it as a string.
Definition: files.cc:38
std::string getContent(const unsigned long int maximumBytes=1<< 20) const
Get the content of the file limited by maximumBytes.
Definition: files.cc:85
std::string fileName
Path of the file.
Definition: files.hpp:41
Class to handle file related operations.
Definition: files.hpp:29
bool isReadable() const
Definition: files.cc:128
unsigned long getId() const
Definition: files.cc:119
fo namespace holds the FOSSology library functions.
const std::string & getFileName() const
Definition: files.cc:94
File(unsigned long id, const char *fileName)
Definition: files.cc:104