|
KittyMemoryEx 1.0.0
Dedicated library for runtime code patching, memory scanning, tracing, injection and some more useful memory utilities. works for both Android and Linux
|
This class provides an interface for file operations. More...
#include <KittyIOFile.hpp>
Public Member Functions | |
| KittyIOFile () | |
| Default constructor creating an uninitialized file object. | |
| KittyIOFile (const std::string &filePath, int flags, mode_t mode=0) | |
| Constructs a new KittyIOFile object with file path, flags, and optional mode. | |
| KittyIOFile (const KittyIOFile &)=delete | |
| KittyIOFile & | operator= (const KittyIOFile &)=delete |
| KittyIOFile (KittyIOFile &&other) noexcept | |
| Move constructor. Transfers ownership of the file descriptor. | |
| KittyIOFile & | operator= (KittyIOFile &&other) noexcept |
| Move assignment operator. Closes current file descriptor and transfers ownership. | |
| bool | open () |
| Opens the file. | |
| bool | close () |
| Closes the file. | |
| int | lastError () const |
| Returns the last error. | |
| std::string | lastStrError () const |
| Returns the last error message. | |
| int | fd () const |
| Returns the file descriptor. | |
| std::string | path () const |
| Returns the file path. | |
| int | flags () const |
| Returns the file flags. | |
| mode_t | mode () const |
| Returns the file mode. | |
| ssize_t | read (void *buffer, size_t len) |
| Reads data from the file and advances file pointer. | |
| ssize_t | write (const void *buffer, size_t len) |
| Writes data to the file and advances file pointer. | |
| ssize_t | pread (kt_off64_t offset, void *buffer, size_t len) |
| Reads data from the file at a given offset without changing file pointer. | |
| ssize_t | pwrite (kt_off64_t offset, const void *buffer, size_t len) |
| Writes data to the file at a given offset without changing file pointer. | |
| bool | exists () const |
| Checks if the file exists. | |
| bool | canRead () const |
| Checks if the file can be read. | |
| bool | canWrite () const |
| Checks if the file can be written. | |
| bool | canExecute () const |
| Checks if the file can be executed. | |
| bool | remove () |
| Removes the file. | |
| kt_stat64_t | info () |
| Retrieves information about the file. | |
| bool | isFile () |
| Checks if the file is a regular file. | |
| bool | readToString (std::string *str) |
| Reads the contents of the file into a string. | |
| bool | readToBuffer (std::vector< char > *buf) |
| Reads the contents of the file into a buffer. | |
| bool | copyToFile (const std::string &filePath) |
| Copies the contents of the file to another file. | |
| bool | copyToFd (int fd) |
| Writes the contents of the file to a file descriptor. | |
Static Public Member Functions | |
| static bool | readFileToString (const std::string &filePath, std::string *str) |
| Reads the contents of a file into a string. | |
| static bool | readFileToBuffer (const std::string &filePath, std::vector< char > *buf) |
| Reads the contents of a file into a buffer. | |
| static bool | copy (const std::string &srcFilePath, const std::string &dstFilePath) |
| Copies the contents of a file to another file. | |
| static bool | listFilesCallback (const std::string &dir, std::function< bool(const std::string &)> cb) |
| Lists files in a directory. | |
| static bool | createDirectoryRecursive (const std::string &path, mode_t mode=0755) |
| Recursively creates a directory path. | |
This class provides an interface for file operations.
|
inline |
Constructs a new KittyIOFile object with file path, flags, and optional mode.
| filePath | The path to the file. |
| flags | The flags for opening the file. |
| mode | The mode/permissions for opening the file (default: 0). |

|
inline |
Checks if the file can be executed.
|
inline |
Checks if the file can be read.
|
inline |
Checks if the file can be written.
| bool KittyIOFile::close | ( | ) |
Closes the file.

|
inlinestatic |
Copies the contents of a file to another file.
| srcFilePath | The source file path. |
| dstFilePath | The destination file path. |

| bool KittyIOFile::copyToFd | ( | int | fd | ) |
Writes the contents of the file to a file descriptor.
| fd | The file descriptor. |


|
inline |
Copies the contents of the file to another file.
| filePath | The file path to write to. |


|
static |
Recursively creates a directory path.
This function creates all intermediate directories in the given path, similar to the behavior of mkdir -p on POSIX systems.
| path | The full directory path to create (absolute or relative). |
| mode | The permissions to use when creating directories (default: 0755). |

|
inline |
Checks if the file exists.
|
inline |
Returns the file descriptor.

|
inline |
Returns the file flags.

|
inline |
Retrieves information about the file.

|
inline |
Checks if the file is a regular file.

|
inline |
Returns the last error.
|
inline |
Returns the last error message.
|
static |
Lists files in a directory.
| dir | The directory path. |
| cb | The callback function to be called for each file. |
|
inline |
Returns the file mode.

| bool KittyIOFile::open | ( | ) |
Opens the file.

|
inline |
Returns the file path.

| ssize_t KittyIOFile::pread | ( | kt_off64_t | offset, |
| void * | buffer, | ||
| size_t | len ) |
Reads data from the file at a given offset without changing file pointer.
| offset | The offset to read from. |
| buffer | The buffer to read into. |
| len | The number of bytes to read. |
| ssize_t KittyIOFile::pwrite | ( | kt_off64_t | offset, |
| const void * | buffer, | ||
| size_t | len ) |
Writes data to the file at a given offset without changing file pointer.
| offset | The offset to write to. |
| buffer | The buffer to write from. |
| len | The number of bytes to write. |
| ssize_t KittyIOFile::read | ( | void * | buffer, |
| size_t | len ) |
Reads data from the file and advances file pointer.
| buffer | The buffer to read into. |
| len | The number of bytes to read. |
|
inlinestatic |
Reads the contents of a file into a buffer.
| filePath | The file path to read from. |
| buf | The buffer to read into. |

|
inlinestatic |
Reads the contents of a file into a string.
| filePath | The file path to read from. |
| str | The string to read into. |

| bool KittyIOFile::readToBuffer | ( | std::vector< char > * | buf | ) |
Reads the contents of the file into a buffer.
| buf | The buffer to read into. |

| bool KittyIOFile::readToString | ( | std::string * | str | ) |
Reads the contents of the file into a string.
| str | The string to read into. |

|
inline |
Removes the file.
| ssize_t KittyIOFile::write | ( | const void * | buffer, |
| size_t | len ) |
Writes data to the file and advances file pointer.
| buffer | The buffer to write from. |
| len | The number of bytes to write. |