|
PMT Renovated main-branch
Partition Manager Tool is a fast, reliable, and feature-rich CLI application for Android devices that enables advanced partition operations such as backup, flashing, erasing, information retrieval, and more.
|
Main namespace of libhelper library. More...
Classes | |
| class | AsyncManager |
| A simple class for easily managing asynchronous operations. More... | |
| class | BasicUniqueFD |
| A class that helps with easy file descriptor management. More... | |
| class | BasicUniqueFP |
| A class that helps with easy file pointer management. More... | |
| class | Capsule |
| A "capsule" class that stores references. More... | |
| struct | CleanupTraits |
It offers a ready-made cleanup() function. It is used by other classes. The default defination takes the type pointer and clears it with delete. More... | |
| struct | CleanupTraits< DIR > |
| struct | CleanupTraits< FILE > |
| struct | CleanupTraits< T[]> |
| class | Closer |
| Valid file descriptor, file pointer and directory pointer closer class structure. Used by default. More... | |
| struct | ConstIfCharPointer |
Add the const qualifier if input type is char*. More... | |
| struct | DeepConst |
Add the const qualifier to the input type. More... | |
| class | Error |
A modern, throwable error class. It provides the << operator and offers usage in the std::print style of modern C++23. More... | |
| class | Logger |
| Modern, functional logger class. More... | |
| class | PureTuple |
| A class that stores tuple data in a list. More... | |
| class | Random |
Generate random numbers with std::mt19937. More... | |
| class | ScopeGuard |
| When an object created within a given scope leaves that scope, the corresponding input function is executed. More... | |
| class | Silencer |
Silence stdout and stderr. More... | |
Concepts | |
| concept | HasCStrFunction |
| Checks whether the input type provides a c_str() member function. | |
| concept | Invocable |
| Checks whether the input is invocable and returns requested type. | |
| concept | PointerDeletable |
The deletionability of the entry is checked using the delete key. Only for pointers/classes! This check is performed using CleanupTraits. It is used by other classes. | |
| concept | ArrayDeletable |
The deletionability of the entry is checked using the delete key. Only for arrays! This check is performed using CleanupTraits. It is used by other classes. | |
| concept | Deletable |
The deletionability of the entry is checked using the delete key. This check is performed using CleanupTraits. It is used by other classes. | |
| concept | IsCloser |
Checks if the input class can close the needed thing, either as a operator() or using the close() function. | |
| concept | IsFullCloser |
Checks if the input class can close the needed thing, either as a operator() and using the close() function. | |
| concept | IsCloserWithOperator |
Check the ownership of operator() in the closer class. | |
| concept | IsCloserWithFunction |
Check the ownership of close() in the closer class. | |
Typedefs | |
| using | UniqueFD = BasicUniqueFD< Closer > |
| using | UniqueFP = BasicUniqueFP< Closer > |
Enumerations | |
| enum | LogLevels { INFO = static_cast<int>('I') , WARNING = static_cast<int>('W') , ERROR = static_cast<int>('E') , ABORT = static_cast<int>('A') } |
| Logging levels. | |
Functions | |
| template<typename PathType > | |
| bool | isExists (PathType &&entry) |
| Checks whether the file/directory exists. | |
| template<typename PathType > | |
| bool | fileIsExists (PathType &&file) |
| Checks whether the file exists. | |
| template<typename PathType > | |
| bool | directoryIsExists (PathType &&path) |
| Checks whether the directory exists. | |
| template<typename PathType > | |
| bool | isLink (PathType &&entry) |
| Checks if the entry is a symbolic link. | |
| template<typename PathType > | |
| bool | isSymbolicLink (PathType &&entry) |
| Checks if the entry is a symbolic link. | |
| template<typename PathType > | |
| bool | isHardLink (PathType &&entry) |
| Checks if the entry is a hard link. | |
| template<typename PathType > | |
| bool | linkIsExists (PathType &&entry) |
| Checks whether the link (symbolic or hard) exists. | |
| template<typename PathType , typename StringType = std::string> | |
| bool | writeFile (PathType &&file, StringType &&text) |
| Writes given text into file. If file does not exist, it is automatically created. | |
| template<typename PathType , typename StringType = std::string> | |
| std::optional< ConstIfCharPointer_t< StringType > > | readFile (PathType &&file) |
| Reads file content into string. | |
| template<typename PathType > | |
| bool | copyFile (PathType &&file, PathType &&dest) |
| Copy file to destination. | |
| bool | makeDirectory (const std::filesystem::path &path) |
| Create directory. | |
| bool | makeRecursiveDirectory (const std::filesystem::path &paths) |
| Create recursive directory. | |
| bool | createFile (const std::filesystem::path &path) |
| Create file. | |
| bool | createSymlink (const std::filesystem::path &entry1, const std::filesystem::path &entry2) |
| Symlink entries. | |
| bool | eraseEntry (const std::filesystem::path &entry) |
| Remove file or empty directory. | |
| bool | eraseDirectoryRecursive (const std::filesystem::path &directory) |
| Remove directory and all directory contents recursively. | |
| template<typename ReturnType = int64_t> requires std::is_integral_v<ReturnType> | |
| ReturnType | fileSize (const std::filesystem::path &file) |
| Get file size. | |
| std::string | readSymlink (const std::filesystem::path &entry) |
| Read symlinks. | |
| bool | areLinked (const std::filesystem::path &entry1, const std::filesystem::path &entry2) |
| It checks if the two entries are linked. | |
| bool | sha256Compare (const std::filesystem::path &file1, const std::filesystem::path &file2) |
| Compare SHA-256 values of files. | |
| std::optional< std::string > | sha256Of (const std::filesystem::path &path) |
| Get SHA-256 of file. | |
| bool | runCommand (const std::string &cmd) |
| Run shell command. | |
| bool | confirmPropt (const std::string &message, int maxTries=10) |
| Shows message and asks for y/N from user. | |
| bool | changeMode (const std::filesystem::path &file, mode_t mode) |
| Changes file permissions. | |
| bool | changeOwner (const std::filesystem::path &file, uid_t uid, gid_t gid) |
| Change file owner (user ID and group ID). | |
| std::string | currentWorkingDirectory () |
| Get current working directory as string. | |
| std::string | currentDate () |
| Get current date as string (format: YYYY-MM-DD). | |
| std::string | currentTime () |
| Get current time as string (format: HH:MM:SS). | |
|
template<typename ExitCodeType = int> requires std::is_integral_v<ExitCodeType> | |
| std::pair< std::string, ExitCodeType > | runCommandWithOutput (const std::string &cmd) |
| Run shell command return output as string. | |
| std::filesystem::path | pathJoin (std::filesystem::path base, const std::filesystem::path &relative) |
| Joins base path with relative path and returns result. | |
| std::filesystem::path | pathBasename (const std::filesystem::path &entry) |
| @briefGet the filename part of given path. | |
| std::filesystem::path | pathDirname (const std::filesystem::path &entry) |
| Get the directory part of given path. | |
|
template<typename Ret = uint64_t, typename T = Ret> requires std::is_integral_v<Ret> && std::is_integral_v<T> && std::is_unsigned_v<Ret> && std::is_unsigned_v<T> | |
| Ret | getRandomOffset (T &&size, T &&bufferSize) |
| Get random offset depending on size and bufferSize. | |
| template<typename Ret = int, typename SizeType = uint64_t> requires std::is_integral_v<Ret> && std::is_integral_v<SizeType> | |
| Ret | convertTo (SizeType size, sizeCastTypes type) |
| Convert input size to input multiple. | |
| std::string | multipleToString (sizeCastTypes type) |
| Convert input multiple variable to string. | |
| template<typename... Args> | |
| std::string | format (std::format_string< Args... > fmt, Args &&...args) |
Format it input and return as std::string. | |
| template<uint64_t size> | |
| int | convertTo (const sizeCastTypes &type) |
| Convert input size to input multiple. | |
| std::string | getLibVersion () |
Get libhelper library version string. | |
| template<std::invocable F> | |
| static auto | makeScopeGuard (F &&fn) noexcept |
| Make scope guard with input function. | |
|
template<typename... Args> requires (sizeof...(Args) >= 2) | |
| auto | openFd (Args &&...args) noexcept |
| Open file (creates file descriptor). | |
|
template<typename... Args> requires (sizeof...(Args) >= 2) | |
| auto | openFp (Args &&...args) noexcept |
| Open file (creates file pointer). | |
|
template<typename... Args> requires (sizeof...(Args) >= 1) | |
| auto | openDir (Args &&...args) noexcept |
| Open directory. | |
Main namespace of libhelper library.
| int Helper::convertTo | ( | const sizeCastTypes & | type | ) |
Convert input size to input multiple.
| size | Size. |
| type | Cast type. |
| Ret Helper::convertTo | ( | SizeType | size, |
| sizeCastTypes | type | ||
| ) |
Convert input size to input multiple.
| Ret | Return type. |
| SizeType | Input size type |
| size | Size. |
| type | Cast type. |
| bool Helper::copyFile | ( | PathType && | file, |
| PathType && | dest | ||
| ) |
Copy file to destination.
| file | File path. |
| dest | Destination. |
| std::string Helper::currentDate | ( | ) |
Get current date as string (format: YYYY-MM-DD).
| Empty String | An error occurred. |
| std::string Helper::currentTime | ( | ) |
Get current time as string (format: HH:MM:SS).
| Empty String | An error occurred. |
| std::string Helper::currentWorkingDirectory | ( | ) |
Get current working directory as string.
| Empty String | An error occurred. |
| bool Helper::directoryIsExists | ( | PathType && | path | ) |
Checks whether the directory exists.
| path | Directory path. |
| bool Helper::fileIsExists | ( | PathType && | file | ) |
Checks whether the file exists.
| file | File path. |
| ReturnType Helper::fileSize | ( | const std::filesystem::path & | file | ) |
Get file size.
| ReturnType | Return type (default is int64_t ). |
| file | File path. |
| bool Helper::isExists | ( | PathType && | entry | ) |
Checks whether the file/directory exists.
| entry | File/directory path. |
| bool Helper::isHardLink | ( | PathType && | entry | ) |
Checks if the entry is a hard link.
| entry | File/directory path. |
| bool Helper::isLink | ( | PathType && | entry | ) |
Checks if the entry is a symbolic link.
| entry | File/directory path. |
| bool Helper::isSymbolicLink | ( | PathType && | entry | ) |
Checks if the entry is a symbolic link.
| entry | Fİle/directory path. |
| bool Helper::linkIsExists | ( | PathType && | entry | ) |
Checks whether the link (symbolic or hard) exists.
| entry | File/directory path. |
|
staticnoexcept |
Make scope guard with input function.
| F | Function reference. |
| fn | Function. |
| std::optional< ConstIfCharPointer_t< StringType > > Helper::readFile | ( | PathType && | file | ) |
Reads file content into string.
On success, returns file content. On error, returns std::nullopt.
| StringType | String type (default is std::string ). |
| file | File path. |
| std::nullopt | Error occurred. |
| StringType | File content. |
| bool Helper::sha256Compare | ( | const std::filesystem::path & | file1, |
| const std::filesystem::path & | file2 | ||
| ) |
Compare SHA-256 values of files.
| file1 | First file path. |
| file2 | Second file path. |
| Helper::Error |
| std::optional< std::string > Helper::sha256Of | ( | const std::filesystem::path & | path | ) |
| bool Helper::writeFile | ( | PathType && | file, |
| StringType && | text | ||
| ) |
Writes given text into file. If file does not exist, it is automatically created.
| StringType | String type (default is std::string ). |
| file | File path. |
| text | Text. |