Skip to content

Commit

Permalink
Updates examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jsc-paneda committed Sep 11, 2024
1 parent 61b32c6 commit 36f6d2f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions examples/esp32/file_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using namespace beauty;

size_t FileIO::openFileForRead(const std::string& id, const Request& request, Reply& reply) {

openReadFiles_[id] = LittleFS.open(reply.filePath_.c_str(), "r");
if (!openReadFiles_[id]) {
openReadFiles_.erase(id);
Expand Down Expand Up @@ -36,15 +35,16 @@ Reply::status_type FileIO::openFileForWrite(const std::string& id,
// only support files under '/' so '/' + max filename = 32
if (reply.filePath_.size() > 32) {
err = "Filename too long max 31 characters are allowed";
return Reply::status_type::bad_request;
return Reply::bad_request;
}

openWriteFiles_[id] = LittleFS.open(reply.filePath_.c_str(), "w");
if (!openWriteFiles_[id]) {
openWriteFiles_.erase(id);
return Reply::status_type::internal_server_error;
return Reply::internal_server_error;
}
return Reply::status_type::ok;

return Reply::ok;
}

Reply::status_type FileIO::writeFile(const std::string& id,
Expand All @@ -59,5 +59,5 @@ Reply::status_type FileIO::writeFile(const std::string& id,
openWriteFiles_.erase(id);
}

return Reply::status_type::ok;
return Reply::ok;
}
4 changes: 2 additions & 2 deletions examples/pc/file_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Reply::status_type FileIO::openFileForWrite(const std::string &id,
std::string fullPath = docRoot_ + reply.filePath_;
std::ofstream &os = openWriteFiles_[id];
os.open(fullPath.c_str(), std::ios::out | std::ios::binary);
return Reply::status_type::ok;
return Reply::ok;
}

Reply::status_type FileIO::writeFile(const std::string &id,
Expand All @@ -56,5 +56,5 @@ Reply::status_type FileIO::writeFile(const std::string &id,
openWriteFiles_[id].close();
openWriteFiles_.erase(id);
}
return Reply::status_type::ok;
return Reply::ok;
}

0 comments on commit 36f6d2f

Please sign in to comment.