Skip to content

Add open function without path #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/UFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions src/UFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading