Data_deduplication_service
Service that will use hashes to deduplicate files
file_services Namespace Reference

file services namespace More...

Classes

class  FileService
 this class handles file/directory management and uses dbManager to perform calls More...
 

Enumerations

enum  dbUsageStrategy { use , create }
 
enum  dataInsetionStrategy { PreserveOld , ReplaceWithNew }
 
enum  dataRetrievalStrategy { Persist , Remove }
 
enum  rootDirectoryHandlingStrategy { NoCreateMain , CreateMain }
 

Functions

tl::expected< std::string, int > checkFileExistence (std::string_view filePath)
 
tl::expected< std::string, int > checkDirectoryExistence (std::string_view dirPath)
 
template<typename T , typename A >
requires std::is_same_v< T, A > std::is_same_v< T, typename std::remove_const< A >::type > std::is_same_v< A, typename std::remove_const< T >::type > int compareBlock (size_t size, T *arr, A *arr2)
 
std::array< size_t, 4 > compareFiles (const fs::path &file1, const fs::path &file2, size_t segmentSize)
 
std::array< size_t, 4 > compareDirectories (const fs::path &file1, const fs::path &file2, size_t segmentSize)
 
fs::path getNormalAbs (const fs::path &path)
 
std::filesystem::path getNormalAbs (const std::filesystem::path &path)
 

Detailed Description

file services namespace

Enumeration Type Documentation

◆ dataInsetionStrategy

File/directories insertion startegy

Enumerator
PreserveOld 

will ignore files that already exist

ReplaceWithNew 

will replace file contents

◆ dataRetrievalStrategy

File/directory handling strategy during load process

Enumerator
Persist 

will leave data as is

Remove 

will delete requested data from database

◆ dbUsageStrategy

Database usage strategy

Enumerator
use 

if database exist connection will be established

create 

create new database if it doesn't exist

◆ rootDirectoryHandlingStrategy

Defines what will be done if destination directory does not exist

Enumerator
NoCreateMain 

will return an error code

CreateMain 

will create this directory using create_directories

Function Documentation

◆ checkDirectoryExistence()

tl::expected< std::string, int > file_services::checkDirectoryExistence ( std::string_view  dirPath)

This function checks existence of a canonical directory path for dir_path

Parameters
dirPath
Returns
canonical dirPath or error code
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkFileExistence()

tl::expected< std::string, int > file_services::checkFileExistence ( std::string_view  filePath)

This function checks existence of a canonical file path for file_path

Parameters
filePath
Returns
canonical filePath or error code
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compareBlock()

template<typename T , typename A >
requires std::is_same_v<T, A> std::is_same_v<T, typename std::remove_const<A>::type> std::is_same_v<A, typename std::remove_const<T>::type> int file_services::compareBlock ( size_t  size,
T *  arr,
A *  arr2 
)
+ Here is the caller graph for this function:

◆ compareDirectories()

std::array< size_t, 4 > file_services::compareDirectories ( const fs::path &  file1,
const fs::path &  file2,
size_t  segmentSize 
)

Compares directory contents

Parameters
file1
file2
segmentSizesize of blocks to check
Returns
{e1,e2,e3,e4}

e1 - number of bytes that differ

e2 - number of segments that differ

e3 - total number of segments

e4 - total number of bytes

+ Here is the call graph for this function:

◆ compareFiles()

std::array< size_t, 4 > file_services::compareFiles ( const fs::path &  file1,
const fs::path &  file2,
size_t  segmentSize 
)

Compares to file paths segment by segment

Parameters
file1
file2
segmentSizesize of blocks to check
Returns
{e1,e2,e3,e4}

e1 - number of bytes that differ

e2 - number of segments that differ

e3 - total number of segments

e4 - total number of bytes

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNormalAbs() [1/2]

fs::path file_services::getNormalAbs ( const fs::path &  path)

Calculates lexically normal absolute path

Parameters
path
Returns
lexically normal absolute path
+ Here is the caller graph for this function:

◆ getNormalAbs() [2/2]

std::filesystem::path file_services::getNormalAbs ( const std::filesystem::path &  path)