lintel 0.2.0
Loading...
Searching...
No Matches
Classes | Public Member Functions | Friends | List of all members
lintel::FileService Class Reference

#include <FileService.h>

Classes

class  Stream
 

Public Member Functions

 FileService (std::filesystem::path path)
 
bool isFile ()
 
bool exists ()
 
std::size_t getSize ()
 
void deleteFile ()
 
std::string readFile ()
 
std::string getName ()
 
std::filesystem::path getPath ()
 
void writeToFile (const std::string &content, bool overwrite=false)
 
void createFile (std::size_t sizeOfFile)
 
void createSymlinkTo (const std::filesystem::path &to)
 
std::vector< std::string > matches (const std::regex &regex)
 
FileService::Stream createStream ()
 

Friends

std::ostream & operator<< (std::ostream &os, const FileService &file)
 

Detailed Description

class for wrapping general operations with a normal file

Constructor & Destructor Documentation

◆ FileService()

lintel::FileService::FileService ( std::filesystem::path  path)
explicit

constructor

Parameters
pathof file

Member Function Documentation

◆ createFile()

void lintel::FileService::createFile ( std::size_t  sizeOfFile)

Creates an empty file with the given size.

Parameters
sizeOfFilethe size to allocate for the new file

◆ createStream()

FileService::Stream lintel::FileService::createStream ( )

creates FileService::Stream for file

Returns
stream

◆ createSymlinkTo()

void lintel::FileService::createSymlinkTo ( const std::filesystem::path &  to)

creates symlink of file to given path

Parameters
topath where to create the sysmlink

◆ deleteFile()

void lintel::FileService::deleteFile ( )

delete file

◆ exists()

bool lintel::FileService::exists ( )

Checks if the given path exists and is a regular file.

Returns
true if the path exists and is a file

◆ getName()

std::string lintel::FileService::getName ( )

returns name of file

Returns
name of file

◆ getPath()

std::filesystem::path lintel::FileService::getPath ( )

returns given path of file

Returns
path of file

◆ getSize()

std::size_t lintel::FileService::getSize ( )

Returns the size of the file in bytes.

Returns
the file size in bytes

◆ isFile()

bool lintel::FileService::isFile ( )

Checks if the given path is a regular file.

Returns
true if the path is a regular file

◆ matches()

std::vector< std::string > lintel::FileService::matches ( const std::regex &  regex)

searches matching string of file via FileService::Stream

Parameters
regexfor searching matching strings
Returns
list of matching lines in right sequence

◆ readFile()

std::string lintel::FileService::readFile ( )

reads whole file in total (not good for big files)

Returns
content of whole file in one string

◆ writeToFile()

void lintel::FileService::writeToFile ( const std::string &  content,
bool  overwrite = false 
)
Parameters
contentto be written in file
overwritereplace existing content instead of appending

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const FileService &  file 
)
friend

to string method


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