# 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

Conversation saved
HOOPSY BETA

### Hello! I'm HOOPSY

Your Docs generative AI assistant. Ask me anything about HOOPS Visualize Web or choose a sample question below to start a conversation:

What is HOOPS Visualize Web?
What are the latest release notes for HOOPS Visualize Web?
How do I start evaluating HOOPS Visualize Web?
How do I write my first sample application?
How can I get assistance?

HOOPSY may store conversations according to OpenAI's policy. Responses may not always be accurate.

HOOPSY is thinking...