FOSSology  4.4.0
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 25 of file files.hpp.

Constructor & Destructor Documentation

◆ File() [1/2]

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

Constructor for File class

Parameters
_idID of the file
_fileNamePath of the file

Definition at line 100 of file files.cc.

◆ File() [2/2]

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 107 of file files.cc.

Member Function Documentation

◆ getContent()

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 81 of file files.cc.

◆ getFileName()

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

Get the current file path

Returns
File path

Definition at line 90 of file files.cc.

◆ getId()

unsigned long File::getId ( ) const

Get the ID of the file

Returns
ID of the file

Definition at line 115 of file files.cc.

◆ isReadable()

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 124 of file files.cc.


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