diff --git a/src/UFile.cpp b/src/UFile.cpp index c7d759a..0ac8b10 100644 --- a/src/UFile.cpp +++ b/src/UFile.cpp @@ -51,6 +51,15 @@ bool UFile::open(String filename, FileMode mode) { return open(filename.c_str(), mode); } +bool UFile::open(FileMode mode) { + if (path.empty()) { + // Path is not set + return false; + } + + return open(path.c_str(), mode); +} + void UFile::close() { // Close the file if (filePointer != nullptr) { diff --git a/src/UFile.h b/src/UFile.h index 105147c..3f1bc8e 100644 --- a/src/UFile.h +++ b/src/UFile.h @@ -52,6 +52,12 @@ class UFile{ */ bool open(String filename, FileMode mode); + /** + * @brief Opens a file that was already initialized with a path. + * @param mode The file mode (READ, WRITE, or APPEND). The default is READ. + * @return True if the file was opened successfully, false otherwise. + */ + bool open(FileMode mode = FileMode::READ); /** * @brief Closes the file and releases any allocated resources.