From 93d9c79828535d2f57c0766f6e69e2d4a0fb3aaf Mon Sep 17 00:00:00 2001 From: Sebastian Romero Date: Mon, 5 May 2025 14:42:18 +0200 Subject: [PATCH] Add open function without path --- src/UFile.cpp | 9 +++++++++ src/UFile.h | 6 ++++++ 2 files changed, 15 insertions(+) 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.