mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-12 01:53:07 +03:00
Various String handling cleanups (#6945)
Use the proper api (::clear(), isEmpty()) instead of doing comparisons/assignments of empty strings. Also fix mixture of tabs and spaces in the source code.
This commit is contained in:
@ -122,7 +122,7 @@ void handleFileUpload() {
|
||||
}
|
||||
DBG_OUTPUT_PORT.print("handleFileUpload Name: "); DBG_OUTPUT_PORT.println(filename);
|
||||
fsUploadFile = filesystem->open(filename, "w");
|
||||
filename = String();
|
||||
filename.clear();
|
||||
} else if (upload.status == UPLOAD_FILE_WRITE) {
|
||||
//DBG_OUTPUT_PORT.print("handleFileUpload Data: "); DBG_OUTPUT_PORT.println(upload.currentSize);
|
||||
if (fsUploadFile) {
|
||||
@ -150,7 +150,7 @@ void handleFileDelete() {
|
||||
}
|
||||
filesystem->remove(path);
|
||||
server.send(200, "text/plain", "");
|
||||
path = String();
|
||||
path.clear();
|
||||
}
|
||||
|
||||
void handleFileCreate() {
|
||||
@ -172,7 +172,7 @@ void handleFileCreate() {
|
||||
return server.send(500, "text/plain", "CREATE FAILED");
|
||||
}
|
||||
server.send(200, "text/plain", "");
|
||||
path = String();
|
||||
path.clear();
|
||||
}
|
||||
|
||||
void handleFileList() {
|
||||
@ -184,7 +184,7 @@ void handleFileList() {
|
||||
String path = server.arg("dir");
|
||||
DBG_OUTPUT_PORT.println("handleFileList: " + path);
|
||||
Dir dir = filesystem->openDir(path);
|
||||
path = String();
|
||||
path.clear();
|
||||
|
||||
String output = "[";
|
||||
while (dir.next()) {
|
||||
@ -275,13 +275,13 @@ void setup(void) {
|
||||
|
||||
//get heap status, analog input value and all GPIO statuses in one json call
|
||||
server.on("/all", HTTP_GET, []() {
|
||||
String json = "{";
|
||||
String json('{');
|
||||
json += "\"heap\":" + String(ESP.getFreeHeap());
|
||||
json += ", \"analog\":" + String(analogRead(A0));
|
||||
json += ", \"gpio\":" + String((uint32_t)(((GPI | GPO) & 0xFFFF) | ((GP16I & 0x01) << 16)));
|
||||
json += "}";
|
||||
server.send(200, "text/json", json);
|
||||
json = String();
|
||||
json.clear();
|
||||
});
|
||||
server.begin();
|
||||
DBG_OUTPUT_PORT.println("HTTP server started");
|
||||
|
@ -209,7 +209,7 @@ void printDirectory() {
|
||||
return returnFail("BAD PATH");
|
||||
}
|
||||
File dir = SD.open((char *)path.c_str());
|
||||
path = String();
|
||||
path.clear();
|
||||
if (!dir.isDirectory()) {
|
||||
dir.close();
|
||||
return returnFail("NOT DIR");
|
||||
|
Reference in New Issue
Block a user