From b2264b53a8b2ee192a4c656322b6cc2ab892d63c Mon Sep 17 00:00:00 2001 From: david gauchard Date: Tue, 11 Aug 2020 01:52:27 +0200 Subject: [PATCH] conditional compilation for the Hook example --- ESPWebDAV.cpp | 2 +- WebDav4WebServer.cpp | 4 ++++ WebDav4WebServer.h | 4 ++++ examples/Hooked/Hooked.ino | 4 ++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ESPWebDAV.cpp b/ESPWebDAV.cpp index 37b5ab8..1c5313c 100644 --- a/ESPWebDAV.cpp +++ b/ESPWebDAV.cpp @@ -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"); diff --git a/WebDav4WebServer.cpp b/WebDav4WebServer.cpp index 0f985e6..3340f3b 100644 --- a/WebDav4WebServer.cpp +++ b/WebDav4WebServer.cpp @@ -1,6 +1,8 @@ #include +#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) @@ -11,3 +13,5 @@ ESP8266WebServer::HookFunction hookWebDAVForWebserver(const String& davRootDir, ESP8266WebServer::CLIENT_MUST_STOP; }; } + +#endif // WEBSERVER_HAS_HOOK diff --git a/WebDav4WebServer.h b/WebDav4WebServer.h index 03121d0..8d6f386 100644 --- a/WebDav4WebServer.h +++ b/WebDav4WebServer.h @@ -5,7 +5,11 @@ #include #include +#if WEBSERVER_HAS_HOOK + extern "C" ESP8266WebServer::HookFunction hookWebDAVForWebserver(const String& davRootDir, ESPWebDAVCore& dav); +#endif // WEBSERVER_HAS_HOOK + #endif // __WEBDAV4WEBSERVER diff --git a/examples/Hooked/Hooked.ino b/examples/Hooked/Hooked.ino index fe79977..a83bfc4 100644 --- a/examples/Hooked/Hooked.ino +++ b/examples/Hooked/Hooked.ino @@ -55,6 +55,10 @@ #include #include +#if !WEBSERVER_HAS_HOOK +#error This sketch needs ESP8266WebServer::HookFunction and ESP8266WebServer::addHook +#endif + #define HOSTNAME "ESPWebDAV" #ifndef STASSID