wavelength 1.0.0
Loading...
Searching...
No Matches
File.h
Go to the documentation of this file.
1#pragma once
2
3#include "utl/Str.h"
4
10class File {
11public:
17 virtual ~File();
18
26 virtual int Read(void *data, int bytes) = 0;
27
35 virtual bool ReadAsync(void *data, int bytes) = 0;
36
44 virtual int Write(const void *data, int bytes) = 0;
45
53 virtual int Seek(int offset, int origin) = 0;
54
56 virtual int Tell() = 0;
57
59 virtual void Flush() = 0;
60
62 virtual bool Eof() = 0;
63
65 virtual bool Fail() = 0;
66
68 virtual int Size() = 0;
69
71 virtual int UncompressedSize() = 0;
72
79 virtual bool ReadDone(int *bytes) = 0;
80};
81
89
102File *NewFile(const char *name, int mode, int flags);
103
110void FileLogInit(const char *file);
111
117void FileInit();
118
125
133void FileMakeLocalPath(String &out, const char *path);
134
143void FileCopyPath(char *out, int size, const char *path);
144
151const char *FileRoot();
152
163const char *FileNormalizePath(const char *path);
164
173const char *FileRelativePath(const char *path, const char *root);
174
182bool FileIsAbsolute(const char *path);
183
191const char *FileGetPath(const char *path);
192
200const char *FileGetExt(const char *path);
201
209const char *FileGetBase(const char *path);
210
218const char *FileLocalize(const char *path);
bool FileIsAbsolute(const char *path)
Report whether a path is absolute.
void FileCopyPath(char *out, int size, const char *path)
Copy a path, or store an empty string for a null path.
void FileInit()
Read the asynchronous file configuration.
const char * FileGetPath(const char *path)
Report the directory of a path.
FileOpenMode
Bits of the open mode of NewFile().
Definition File.h:83
@ FILE_OPEN_READ
Definition File.h:85
@ FILE_OPEN_CREATE
Definition File.h:86
@ FILE_OPEN_WRITE
Definition File.h:84
@ FILE_OPEN_TRUNCATE
Definition File.h:87
void FileLogInit(const char *file)
Open the file log, which lists every file the program reads.
File * NewFile(const char *name, int mode, int flags)
Open a file from the archive or the host.
void FileMakeLocalPath(String &out, const char *path)
Store a path as the host opens it.
const char * FileNormalizePath(const char *path)
Lower-case a path, turn backslashes into slashes, and resolve .
const char * FileRoot()
Report the working directory at the first call, normalised.
const char * FileGetExt(const char *path)
Report the extension of a path.
const char * FileLocalize(const char *path)
Express a path relative to the root, as the archive indexes it.
void FileTerminate()
Close the file log.
const char * FileRelativePath(const char *path, const char *root)
Express a path relative to a directory, both normalised.
const char * FileGetBase(const char *path)
Report the file name of a path without its directory or extension.
Open file of the host or the disc.
Definition file.h:29
virtual int UncompressedSize()=0
virtual ~File()
Close the file.
virtual int Read(void *data, int bytes)=0
Read bytes and wait for them.
virtual int Size()=0
virtual int Seek(int offset, int origin)=0
Move the position.
virtual bool Fail()=0
virtual int Write(const void *data, int bytes)=0
Write bytes.
virtual int Tell()=0
virtual bool ReadAsync(void *data, int bytes)=0
Start a read that ReadDone() finishes.
virtual void Flush()=0
Write out buffered data.
virtual bool ReadDone(int *bytes)=0
Report whether the read ReadAsync() started has finished.
virtual bool Eof()=0
Growable text buffer that is also a PrnStream.
Definition string.h:19