mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
fix SDWebServer sample
This commit is contained in:
parent
b330cb794a
commit
ce73ac216b
@ -55,7 +55,6 @@ void returnOK(){
|
|||||||
message += "Access-Control-Allow-Origin: *\r\n";
|
message += "Access-Control-Allow-Origin: *\r\n";
|
||||||
message += "\r\n";
|
message += "\r\n";
|
||||||
client.print(message);
|
client.print(message);
|
||||||
message = 0;
|
|
||||||
client.stop();
|
client.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +68,6 @@ void returnFail(String msg){
|
|||||||
message += msg;
|
message += msg;
|
||||||
message += "\r\n";
|
message += "\r\n";
|
||||||
client.print(message);
|
client.print(message);
|
||||||
message = 0;
|
|
||||||
client.stop();
|
client.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,8 +106,8 @@ bool loadFromSdCard(String path){
|
|||||||
head += "\r\nAccess-Control-Allow-Origin: *";
|
head += "\r\nAccess-Control-Allow-Origin: *";
|
||||||
head += "\r\n\r\n";
|
head += "\r\n\r\n";
|
||||||
client.print(head);
|
client.print(head);
|
||||||
dataType = 0;
|
dataType = String();
|
||||||
path = 0;
|
path = String();
|
||||||
|
|
||||||
uint8_t obuf[WWW_BUF_SIZE];
|
uint8_t obuf[WWW_BUF_SIZE];
|
||||||
|
|
||||||
@ -172,11 +170,11 @@ void deleteRecursive(String path){
|
|||||||
entry.close();
|
entry.close();
|
||||||
SD.remove((char *)entryPath.c_str());
|
SD.remove((char *)entryPath.c_str());
|
||||||
}
|
}
|
||||||
entryPath = 0;
|
entryPath = String();
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
SD.rmdir((char *)path.c_str());
|
SD.rmdir((char *)path.c_str());
|
||||||
path = 0;
|
path = String();
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +184,7 @@ void handleDelete(){
|
|||||||
if(path == "/" || !SD.exists((char *)path.c_str())) return returnFail("BAD PATH");
|
if(path == "/" || !SD.exists((char *)path.c_str())) return returnFail("BAD PATH");
|
||||||
deleteRecursive(path);
|
deleteRecursive(path);
|
||||||
returnOK();
|
returnOK();
|
||||||
path = 0;
|
path = String();
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleCreate(){
|
void handleCreate(){
|
||||||
@ -203,7 +201,7 @@ void handleCreate(){
|
|||||||
SD.mkdir((char *)path.c_str());
|
SD.mkdir((char *)path.c_str());
|
||||||
}
|
}
|
||||||
returnOK();
|
returnOK();
|
||||||
path = 0;
|
path = String();
|
||||||
}
|
}
|
||||||
|
|
||||||
void printDirectory() {
|
void printDirectory() {
|
||||||
@ -211,7 +209,7 @@ void printDirectory() {
|
|||||||
String path = server.arg("dir");
|
String path = server.arg("dir");
|
||||||
if(path != "/" && !SD.exists((char *)path.c_str())) return returnFail("BAD PATH");
|
if(path != "/" && !SD.exists((char *)path.c_str())) return returnFail("BAD PATH");
|
||||||
File dir = SD.open((char *)path.c_str());
|
File dir = SD.open((char *)path.c_str());
|
||||||
path = 0;
|
path = String();
|
||||||
if(!dir.isDirectory()){
|
if(!dir.isDirectory()){
|
||||||
dir.close();
|
dir.close();
|
||||||
return returnFail("NOT DIR");
|
return returnFail("NOT DIR");
|
||||||
@ -242,7 +240,7 @@ void printDirectory() {
|
|||||||
output += "]";
|
output += "]";
|
||||||
client.write(output.c_str(), output.length());
|
client.write(output.c_str(), output.length());
|
||||||
client.stop();
|
client.stop();
|
||||||
output = 0;
|
output = String();
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleNotFound(){
|
void handleNotFound(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user