Skip to content

Commit

Permalink
conditional compilation for the Hook example
Browse files Browse the repository at this point in the history
  • Loading branch information
d-a-v committed Aug 10, 2020
1 parent 99d332d commit b2264b5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ESPWebDAV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ bool ESPWebDAVCore::copyFile(File srcFile, const String& destName)
///XXX USE STREAMTO
yield();
char cp[128];
auto nb = srcFile.read((uint8_t*)cp, sizeof(cp));
int nb = srcFile.read((uint8_t*)cp, sizeof(cp));
if (!nb)
{
DBG_PRINTF("copy: short read\n");
Expand Down
4 changes: 4 additions & 0 deletions WebDav4WebServer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

#include <WebDav4WebServer.h>

#if WEBSERVER_HAS_HOOK

ESP8266WebServer::HookFunction hookWebDAVForWebserver(const String& davRootDir, ESPWebDAVCore& dav)
{
return [&dav, davRootDir](const String & method, const String & url, WiFiClient * client, ESP8266WebServer::ContentTypeFunction contentType)
Expand All @@ -11,3 +13,5 @@ ESP8266WebServer::HookFunction hookWebDAVForWebserver(const String& davRootDir,
ESP8266WebServer::CLIENT_MUST_STOP;
};
}

#endif // WEBSERVER_HAS_HOOK
4 changes: 4 additions & 0 deletions WebDav4WebServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#include <ESPWebDAV.h>
#include <ESP8266WebServer.h>

#if WEBSERVER_HAS_HOOK

extern "C"
ESP8266WebServer::HookFunction hookWebDAVForWebserver(const String& davRootDir, ESPWebDAVCore& dav);

#endif // WEBSERVER_HAS_HOOK

#endif // __WEBDAV4WEBSERVER
4 changes: 4 additions & 0 deletions examples/Hooked/Hooked.ino
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
#include <LittleFS.h>
#include <WebDav4WebServer.h>

#if !WEBSERVER_HAS_HOOK
#error This sketch needs ESP8266WebServer::HookFunction and ESP8266WebServer::addHook
#endif

#define HOSTNAME "ESPWebDAV"

#ifndef STASSID
Expand Down

0 comments on commit b2264b5

Please sign in to comment.