@@ -16,22 +16,30 @@ Initialise a File System instance with a MicroPython Intel Hex string and start
16
16
var micropythonFs = new microbitFs.MicropythonFsHex (IntelHexStr);
17
17
var micropythonFsWithFiles = = new microbitFs.MicropythonFsHex (UploadedHexWithUserFiles);
18
18
19
+ // Import files from a different MicroPython hex file with filesystem
19
20
var addedFilenames = micropythonFs .importFilesFromIntelHex (UploadedHexWithUserFiles);
21
+ addedFilenames = micropythonFs .importFilesFromIntelHex (UploadedHexWithUserFiles, {overwrite: false , formatFirst: false });
20
22
23
+ // File operations
21
24
micropythonFs .create (' filename.txt' , ' Error thrown if file already exists.' );
22
- micropythonFs .write (' filename.txt' , ' Create or overwrites file.' );
25
+ micropythonFs .write (' filename.txt' , ' Create or overwrite a file.' );
23
26
// Append not yet implemented
24
- micropythonFs .append (' filename.txt' , ' Adds additional content.' );
25
- var content = micropythonFs .read (' filename.txt' );
26
- var contentByteArray = micropythonFs .readBytes (' filename.txt' );
27
+ micropythonFs .append (' filename.txt' , ' Add additional content.' );
28
+ var fileContent = micropythonFs .read (' filename.txt' );
29
+ var fileContentByteArray = micropythonFs .readBytes (' filename.txt' );
27
30
if (micropythonFs .exists (' filename.txt' )) {
28
31
micropythonFs .remove (' filename.txt' );
29
32
}
30
33
var fileSizeInBytes = micropythonFs .size (' filename.txt' );
31
34
var fileList = micropythonFs .ls ();
32
35
36
+ // Filesystem size information
37
+ var fsSize = micropythonFs .getStorageSize ();
38
+ var fsAvailableSize = micropythonFs .getStorageUsed ();
39
+ var fsUsedSize = micropythonFs .getStorageRemaining ();
40
+
41
+ // Generate a new hex string with MicroPython and the files
33
42
var intelHexWithFs = micropythonFs .getIntelHex ();
34
- var MicroPythonFsSize = micropythonFs .getFsSize ();
35
43
```
36
44
37
45
Public interface can be found in the ` src/fs-interface.ts ` file.
@@ -50,7 +58,6 @@ if (microbitFs.isAppendedScriptPresent(finalHexStr)) {
50
58
51
59
``` js
52
60
var uicrData = getIntelHexUicrData (IntelHexStr);
53
- console .log (' ' + );
54
61
console .log (' Flash Page Size:' + uicrData .flashPageSize );
55
62
console .log (' Runtime Start Page:' + uicrData .runtimeStartPage );
56
63
console .log (' Runtime Start Address:' + uicrData .runtimeStartAddress );
0 commit comments