Adaptyst
A comprehensive and architecture-agnostic performance analysis tool
Loading...
Searching...
No Matches
adaptyst::Archive Class Reference

#include <archive.hpp>

Classes

class  AlreadyClosedException
 
class  CloseException
 
class  Exception
 
class  FileDoesNotExistException
 
class  FileExistsException
 
class  FileIOException
 
class  FileOpenException
 
class  InitException
 
class  NotRegularFileException
 

Public Member Functions

 Archive (fs::path path, unsigned int buf_size=1024)
 
 Archive (std::unique_ptr< Connection > &conn, bool padding=true, unsigned int buf_size=1024)
 
void add_file (std::string filename, fs::path path)
 
void add_file_stream (std::string filename, std::istream &stream, unsigned int size)
 
void close ()
 
 ~Archive ()
 

Detailed Description

A class describing an archive file to be written to.

Constructor & Destructor Documentation

◆ Archive() [1/2]

adaptyst::Archive::Archive ( fs::path path,
unsigned int buf_size = 1024 )

Constructs an Archive object and opens a file for writing.

When the object is destructed, the file is guaranteed to be properly closed, but without any promises about whether all remaining data have been written. Therefore, you should explicitly call close() (which may throw an exception) before the object goes out of scope.

Parameters
pathThe path to an archive file to be created. The file must not exist yet.
buf_sizeA number of bytes of the internal buffers.

◆ Archive() [2/2]

adaptyst::Archive::Archive ( std::unique_ptr< Connection > & conn,
bool padding = true,
unsigned int buf_size = 1024 )

Constructs an Archive object with all archive file data to be sent through a Connection object.

When the object is destructed, the connection is guaranteed to be properly closed and all remaining data are guaranteed to have been written. Therefore, you DO NOT need to call close() before the object goes out of scope or anywhere else.

Parameters
connA Connection object which all archive file data will be sent through.
paddingWhether padding is allowed to be added to the last block of the archive file data if necessary. If you are not sure, this should be set to true (default).
buf_sizeA number of bytes of the internal buffers.

◆ ~Archive()

adaptyst::Archive::~Archive ( )

Member Function Documentation

◆ add_file()

void adaptyst::Archive::add_file ( std::string filename,
fs::path path )

Adds a file to the root of the archive file.

Parameters
filenameThe name of a file that will appear inside the archive.
pathThe path to a file to be added to the archive. The file must be a regular file and not a directory.

◆ add_file_stream()

void adaptyst::Archive::add_file_stream ( std::string filename,
std::istream & stream,
unsigned int size )

Saves data extracted from a stream to the root of the archive file as a regular file.

Parameters
filenameThe name of a file that will appear inside the archive.
streamA stream containing data to be saved to the archive.
sizeA number of bytes to save to the archive. If it's larger than the actual file size, the entire file will be added, followed by padding with zeroes.

◆ close()

void adaptyst::Archive::close ( )

Closes the file/connection and makes sure that all remaining data have been written.


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