Skip to content

Commit d337f26

Browse files
committed
send code to check/create folders if they don't exist
1 parent 17377d2 commit d337f26

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

examples/uartUploadZIP.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,13 @@
8383
return file.async("binarystring");
8484
}).then(data => {
8585
if (data.length==0) {
86-
console.log("Can't restore files of length 0, ignoring "+path);
86+
// If the path ends with a slash, it's a directory, which we should create if it doesn't exist
87+
if (path[path.length-1]=="/") {
88+
console.log("Creating directory "+path);
89+
UART.getConnection().write(`\x10if (!require("fs").statSync(${JSON.stringify(path)})) require("fs").mkdir(${JSON.stringify(path)});\n`);
90+
} else {
91+
console.log("Can't restore files of length 0, ignoring "+path);
92+
}
8793
} else {
8894
var crc = CRC32(data.substring(0,1024)); // CRC first kb
8995
var existing = files.find(f => f.fn.toUpperCase()==path.toUpperCase());

0 commit comments

Comments
 (0)