Skip to content

Commit

Permalink
send code to check/create folders if they don't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Sep 20, 2024
1 parent 17377d2 commit d337f26
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion examples/uartUploadZIP.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@
return file.async("binarystring");
}).then(data => {
if (data.length==0) {
console.log("Can't restore files of length 0, ignoring "+path);
// If the path ends with a slash, it's a directory, which we should create if it doesn't exist
if (path[path.length-1]=="/") {
console.log("Creating directory "+path);
UART.getConnection().write(`\x10if (!require("fs").statSync(${JSON.stringify(path)})) require("fs").mkdir(${JSON.stringify(path)});\n`);
} else {
console.log("Can't restore files of length 0, ignoring "+path);
}
} else {
var crc = CRC32(data.substring(0,1024)); // CRC first kb
var existing = files.find(f => f.fn.toUpperCase()==path.toUpperCase());
Expand Down

0 comments on commit d337f26

Please sign in to comment.