1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-27 18:02:17 +03:00

Resolve naming conflicts between FS and SD library

This commit is contained in:
Ivan Grokhotkov
2015-08-05 08:36:43 -04:00
parent be2303f198
commit 5cbaa57af9
6 changed files with 19 additions and 3 deletions

View File

@ -21,6 +21,8 @@
#include "FS.h" #include "FS.h"
#include "FSImpl.h" #include "FSImpl.h"
using namespace fs;
static bool sflags(const char* mode, OpenMode& om, AccessMode& am); static bool sflags(const char* mode, OpenMode& om, AccessMode& am);
size_t File::write(uint8_t c) { size_t File::write(uint8_t c) {

View File

@ -24,6 +24,8 @@
#include <Arduino.h> #include <Arduino.h>
#include <memory> #include <memory>
namespace fs {
class File; class File;
class Dir; class Dir;
@ -106,6 +108,12 @@ protected:
}; };
} // namespace fs
using fs::FS;
using fs::File;
using fs::Dir;
extern FS SPIFFS; extern FS SPIFFS;
#endif //FS_H #endif //FS_H

View File

@ -23,6 +23,8 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
namespace fs {
class FileImpl { class FileImpl {
public: public:
virtual ~FileImpl() { } virtual ~FileImpl() { }
@ -67,5 +69,6 @@ public:
}; };
} // namespace fs
#endif //FSIMPL_H #endif //FSIMPL_H

View File

@ -32,6 +32,8 @@ extern "C" {
#include "spi_flash.h" #include "spi_flash.h"
} }
using namespace fs;
extern int32_t spiffs_hal_write(uint32_t addr, uint32_t size, uint8_t *src); extern int32_t spiffs_hal_write(uint32_t addr, uint32_t size, uint8_t *src);
extern int32_t spiffs_hal_erase(uint32_t addr, uint32_t size); extern int32_t spiffs_hal_erase(uint32_t addr, uint32_t size);
extern int32_t spiffs_hal_read(uint32_t addr, uint32_t size, uint8_t *dst); extern int32_t spiffs_hal_read(uint32_t addr, uint32_t size, uint8_t *dst);

View File

@ -24,6 +24,7 @@
#include <Arduino.h> #include <Arduino.h>
#include "WiFiServer.h" #include "WiFiServer.h"
#include "WiFiClient.h" #include "WiFiClient.h"
#include "FS.h"
#include "ESP8266WebServer.h" #include "ESP8266WebServer.h"
#include "detail/RequestHandler.h" #include "detail/RequestHandler.h"
// #define DEBUG // #define DEBUG
@ -77,7 +78,7 @@ void ESP8266WebServer::_addRequestHandler(RequestHandler* handler) {
} }
} }
void ESP8266WebServer::serveStatic(const char* uri, FS fs, const char* path) { void ESP8266WebServer::serveStatic(const char* uri, FS& fs, const char* path) {
_addRequestHandler(new StaticRequestHandler(fs, uri)); _addRequestHandler(new StaticRequestHandler(fs, uri));
} }

View File

@ -25,7 +25,6 @@
#define ESP8266WEBSERVER_H #define ESP8266WEBSERVER_H
#include <functional> #include <functional>
#include <FS.h>
enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE }; enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE };
enum HTTPUploadStatus { UPLOAD_FILE_START, UPLOAD_FILE_WRITE, UPLOAD_FILE_END }; enum HTTPUploadStatus { UPLOAD_FILE_START, UPLOAD_FILE_WRITE, UPLOAD_FILE_END };
@ -39,6 +38,7 @@ enum HTTPUploadStatus { UPLOAD_FILE_START, UPLOAD_FILE_WRITE, UPLOAD_FILE_END };
#define CONTENT_LENGTH_NOT_SET ((size_t) -2) #define CONTENT_LENGTH_NOT_SET ((size_t) -2)
class RequestHandler; class RequestHandler;
class FS;
typedef struct { typedef struct {
HTTPUploadStatus status; HTTPUploadStatus status;
@ -62,7 +62,7 @@ public:
typedef std::function<void(void)> THandlerFunction; typedef std::function<void(void)> THandlerFunction;
void on(const char* uri, THandlerFunction handler); void on(const char* uri, THandlerFunction handler);
void on(const char* uri, HTTPMethod method, THandlerFunction fn); void on(const char* uri, HTTPMethod method, THandlerFunction fn);
void serveStatic(const char* uri, FS fs, const char* path); void serveStatic(const char* uri, FS& fs, const char* path);
void onNotFound(THandlerFunction fn); //called when handler is not assigned void onNotFound(THandlerFunction fn); //called when handler is not assigned
void onFileUpload(THandlerFunction fn); //handle file uploads void onFileUpload(THandlerFunction fn); //handle file uploads