FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
fo::File Class Reference

Class to handle file related operations. More...

#include <files.hpp>

Collaboration diagram for fo::File:
Collaboration graph

Public Member Functions

 File (unsigned long id, const char *fileName)
 
 File (unsigned long id, std::string const &fileName)
 
unsigned long getId () const
 
std::string getContent (const unsigned long int maximumBytes=1<< 20) const
 Get the content of the file limited by maximumBytes. More...
 
const std::string & getFileName () const
 
bool isReadable () const
 

Private Attributes

unsigned long id
 ID of the file.
 
std::string fileName
 Path of the file.
 

Detailed Description

Class to handle file related operations.

Definition at line 29 of file files.hpp.

Constructor & Destructor Documentation

File::File ( unsigned long  _id,
const char *  _fileName 
)

Constructor for File class

Parameters
_idID of the file
_fileNamePath of the file

Definition at line 104 of file files.cc.

File::File ( unsigned long  id,
std::string const &  fileName 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 111 of file files.cc.

Member Function Documentation

std::string File::getContent ( const unsigned long int  maximumBytes = 1 << 20) const

Get the content of the file limited by maximumBytes.

Parameters
maximumBytesLimit of file content to read (set -1 to read full content).
Returns
Content of the file as a string.
See also
fo::getStringFromFile()

Definition at line 85 of file files.cc.

const std::string & File::getFileName ( ) const

Get the current file path

Returns
File path

Definition at line 94 of file files.cc.

unsigned long File::getId ( ) const

Get the ID of the file

Returns
ID of the file

Definition at line 119 of file files.cc.

bool File::isReadable ( ) const

Check if the file is accessible and readable

Returns
True if the the file is readable, false otherwise

Definition at line 128 of file files.cc.


The documentation for this class was generated from the following files: