AbstractFile

Content

class

File

class

File_Manager

Types

State

Position

Fields

None

Again

Failed

ReadOnly

ReadWrite

Begin

Current

End

Functions

~AbstractFile

AbstractFile

AbstractFile

void

SetPath

path const &

GetPath

State

GetState

bool

IsOpen

void

Release

State

AcquireReadOnly

State

AcquireReadWrite

int64_t

Seek

bool

Truncate

int64_t

Size

size_t

Read

size_t

Write

bool

Flush

Detailed Description

class AbstractFile

The AbstractFile class to represent a file or any equivalent. It’s the main interface to read from or write to anything for the SC Store. The following pure virtual methods need to be implemented:

  • DoAcquire

  • DoRelease

  • DoSeek

  • DoTruncate

  • DoGetSize

  • DoRead

  • DoWrite

  • DoFlush SC Store will never directly create file objects, it will ask AbstractFilesystem to to it.

Public Types

enum class State

Indicates the status of the file.

Values:

enumerator None

Not initialized yet.

enumerator Again

Cannot access to the resource because it’s already used.

enumerator Failed

Cannot access to the resource.

enumerator ReadOnly

Resource accessible only for read.

enumerator ReadWrite

Resource fully accessible.

enum class Position

Position for seek operations

Values:

enumerator Begin
enumerator Current
enumerator End

Public Functions

virtual ~AbstractFile()
AbstractFile()

Empty Initialization. Usualy do nothing with the resource.

AbstractFile(path const &path)

Initialization with a given path. The _path property is updated by the default implemenation.

void SetPath(path const &path)
inline path const &GetPath() const
inline State GetState() const
inline bool IsOpen() const
void Release()

The following functions will handle some internal stuff then, the custom version Do*() will be called.

State AcquireReadOnly(bool create_if_missing)
State AcquireReadWrite(bool create_if_missing, bool truncate)
int64_t Seek(int64_t offset, Position position = Position::Begin)

returns offset from begin

bool Truncate()

at current offset return true if it worked

int64_t Size() const
size_t Read(void *data, size_t n_bytes)
size_t Write(void const *data, size_t n_bytes)
bool Flush()

Friends

friend class TC::IO::File
friend class TC::IO::File_Manager