Skip to content

Commit 93d9c79

Browse files
committed
Add open function without path
1 parent cef80be commit 93d9c79

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/UFile.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ bool UFile::open(String filename, FileMode mode) {
5151
return open(filename.c_str(), mode);
5252
}
5353

54+
bool UFile::open(FileMode mode) {
55+
if (path.empty()) {
56+
// Path is not set
57+
return false;
58+
}
59+
60+
return open(path.c_str(), mode);
61+
}
62+
5463
void UFile::close() {
5564
// Close the file
5665
if (filePointer != nullptr) {

src/UFile.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ class UFile{
5252
*/
5353
bool open(String filename, FileMode mode);
5454

55+
/**
56+
* @brief Opens a file that was already initialized with a path.
57+
* @param mode The file mode (READ, WRITE, or APPEND). The default is READ.
58+
* @return True if the file was opened successfully, false otherwise.
59+
*/
60+
bool open(FileMode mode = FileMode::READ);
5561

5662
/**
5763
* @brief Closes the file and releases any allocated resources.

0 commit comments

Comments
 (0)