Skip to content

Commit 5cbaa57

Browse files
committed
Resolve naming conflicts between FS and SD library
1 parent be2303f commit 5cbaa57

File tree

6 files changed

+19
-3
lines changed

6 files changed

+19
-3
lines changed

cores/esp8266/FS.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include "FS.h"
2222
#include "FSImpl.h"
2323

24+
using namespace fs;
25+
2426
static bool sflags(const char* mode, OpenMode& om, AccessMode& am);
2527

2628
size_t File::write(uint8_t c) {

cores/esp8266/FS.h

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <Arduino.h>
2525
#include <memory>
2626

27+
namespace fs {
28+
2729
class File;
2830
class Dir;
2931

@@ -106,6 +108,12 @@ class FS
106108

107109
};
108110

111+
} // namespace fs
112+
113+
using fs::FS;
114+
using fs::File;
115+
using fs::Dir;
116+
109117
extern FS SPIFFS;
110118

111119
#endif //FS_H

cores/esp8266/FSImpl.h

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include <stddef.h>
2424
#include <stdint.h>
2525

26+
namespace fs {
27+
2628
class FileImpl {
2729
public:
2830
virtual ~FileImpl() { }
@@ -67,5 +69,6 @@ class FSImpl {
6769

6870
};
6971

72+
} // namespace fs
7073

7174
#endif //FSIMPL_H

cores/esp8266/spiffs_api.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ extern "C" {
3232
#include "spi_flash.h"
3333
}
3434

35+
using namespace fs;
36+
3537
extern int32_t spiffs_hal_write(uint32_t addr, uint32_t size, uint8_t *src);
3638
extern int32_t spiffs_hal_erase(uint32_t addr, uint32_t size);
3739
extern int32_t spiffs_hal_read(uint32_t addr, uint32_t size, uint8_t *dst);

libraries/ESP8266WebServer/src/ESP8266WebServer.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <Arduino.h>
2525
#include "WiFiServer.h"
2626
#include "WiFiClient.h"
27+
#include "FS.h"
2728
#include "ESP8266WebServer.h"
2829
#include "detail/RequestHandler.h"
2930
// #define DEBUG
@@ -77,7 +78,7 @@ void ESP8266WebServer::_addRequestHandler(RequestHandler* handler) {
7778
}
7879
}
7980

80-
void ESP8266WebServer::serveStatic(const char* uri, FS fs, const char* path) {
81+
void ESP8266WebServer::serveStatic(const char* uri, FS& fs, const char* path) {
8182
_addRequestHandler(new StaticRequestHandler(fs, uri));
8283
}
8384

libraries/ESP8266WebServer/src/ESP8266WebServer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#define ESP8266WEBSERVER_H
2626

2727
#include <functional>
28-
#include <FS.h>
2928

3029
enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE };
3130
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 };
3938
#define CONTENT_LENGTH_NOT_SET ((size_t) -2)
4039

4140
class RequestHandler;
41+
class FS;
4242

4343
typedef struct {
4444
HTTPUploadStatus status;
@@ -62,7 +62,7 @@ class ESP8266WebServer
6262
typedef std::function<void(void)> THandlerFunction;
6363
void on(const char* uri, THandlerFunction handler);
6464
void on(const char* uri, HTTPMethod method, THandlerFunction fn);
65-
void serveStatic(const char* uri, FS fs, const char* path);
65+
void serveStatic(const char* uri, FS& fs, const char* path);
6666
void onNotFound(THandlerFunction fn); //called when handler is not assigned
6767
void onFileUpload(THandlerFunction fn); //handle file uploads
6868

0 commit comments

Comments
 (0)