Skip to content

Commit d4da8ea

Browse files
updated info in docs/README.md
1 parent e02bdbe commit d4da8ea

File tree

2 files changed

+53
-6
lines changed

2 files changed

+53
-6
lines changed

docs/README.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,22 @@ void setup(){
1414
storageMedium.begin();
1515
}
1616
```
17-
You can initialize a Arduino_UnifiedStorage object of each type (QSPI, SD, USB), and copy files and folders from one medium to another.
17+
18+
There is also an overloaded version of the `begin()` method that takes in an argument of type `FileSystems` (can be `FS_FAT` or `FS_LITTLEFS`)
19+
```
20+
void setup(){
21+
storageMedium.begin(FS_FAT);
22+
}
23+
```
24+
### Format QSPI Flash, SD cards, and USB mass storage devices
25+
This library also allows you to format any partition or drive to either FAT or LittleFS filesystems.
26+
27+
```storageMedium.formatFAT()```
28+
or
29+
```storageMedium.formatLittleFS();```
30+
31+
Please make sure you call format before calling `begin()` or after calling `unmount()`.
32+
1833

1934
### Open, Write, and Read Files
2035

@@ -103,6 +118,9 @@ In this example, the `available()` method is called to retrieve the number of av
103118

104119
These methods are useful for scenarios where you need to navigate to a specific position in a file or check the availability of data before performing read operations.
105120

121+
### Close files
122+
Closing files is extremely important as filesystems might fail to unmount if files are kept open. You can close files by calling `file.close()`
123+
106124
### File Manipulation
107125
The library provides various file manipulation operations such as renaming, deleting, moving, and copying files.
108126

@@ -131,6 +149,13 @@ Folder destination = storageMedium.getRootFolder().createSubfolder("destination"
131149
bool success = document.moveTo(destination);
132150
```
133151

152+
This method also allows you to set the behaviour if there's an existing file with the same name at the location you want to move to. You can set the optional parameter `overwrite` to `true`.
153+
```cpp
154+
bool success = document.moveTo(destination, true);
155+
```
156+
157+
158+
Please note that the `File`` object will point now to the moved file, not the original one.
134159
#### Copying a File
135160

136161
You can copy a file to a different directory using the `copyTo()` method.
@@ -140,6 +165,13 @@ Folder destination = storageMedium.getRootFolder().createSubfolder("destination"
140165
bool success = document.copyTo(destination);
141166
```
142167

168+
This method also allows you to set the behaviour if there's an existing file with the same name at the location you want to move to. You can set the optional parameter `overwrite` to `true`.
169+
```cpp
170+
bool success = document.copyTo(destination, true);
171+
```
172+
173+
Please note that the `UFile` object will point now to the copy of the file, not the original one.
174+
143175
### Folder Manipulation
144176
The library provides methods to create, rename, delete, move, copy, and list directories.
145177

@@ -176,6 +208,13 @@ You can move a directory to a different location using the `moveTo()` method.
176208
Folder destination = storageMedium.getRootFolder().createSubfolder("destination");
177209
bool success = newFolder.moveTo(destination);
178210
```
211+
This method also allows you to set the behaviour if there's an existing Folder with the same name at the location you want to move to. You can set the optional parameter `overwrite` to `true`.
212+
```cpp
213+
bool success = newFolder.moveTo(destination, true);
214+
```
215+
216+
Please note that the `Folder`` object will point now to the moved folder.
217+
179218

180219
#### Copying a Folder
181220

@@ -186,6 +225,14 @@ Folder destination = storageMedium.getRootFolder().createSubfolder("destination"
186225
bool success = newFolder.copyTo(destination);
187226
```
188227

228+
This method also allows you to set the behaviour if there's an existing Folder with the same name at the location you want to move to. You can set the optional parameter `overwrite` to `true`.
229+
```cpp
230+
bool success = newFolder.copyTo(destination, true);
231+
```
232+
233+
Please note that the `Folder`` object will point now to the copy of the folder, not the original one.
234+
235+
189236
#### Listing Files and Directories
190237

191238
You can get a list of files and directories in a directory using the `getFiles()` and `getFolders()` methods.

examples/tests/TestUnified/TestUnified.ino

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <Arduino_UnifiedStorage.h>
22

33
#define HAS_USB
4-
//#define HAS_SD
4+
#define HAS_SD
55
#define HAS_QSPI
66

77
#if defined(HAS_USB)
@@ -13,7 +13,7 @@ SDStorage * sd = new SDStorage();
1313
#endif
1414

1515
#if defined(HAS_QSPI)
16-
InternalStorage * qspi = new InternalStorage(2, "user", FS_FAT);
16+
InternalStorage * qspi = new InternalStorage();
1717
#endif
1818

1919

@@ -216,9 +216,9 @@ void setup(){
216216
sd_and_usb();
217217
qspi_and_sd();
218218
Serial.println("Tests finished, formatting all partitions back to FAT:");
219-
Serial.println("\t * Formatting QSPI to FAT:" + String(qspi->formatFAT()));
220-
Serial.println("\t * Formatting SD to FAT:" + String(sd->formatFAT()));
221-
Serial.println("\t * Formatting USB to FAT:" + String(usb->formatFAT()));
219+
Serial.println("\t * Formatting QSPI to FAT: " + String(qspi->formatFAT()));
220+
Serial.println("\t * Formatting SD to FAT: " + String(sd->formatFAT()));
221+
Serial.println("\t * Formatting USB to FAT: " + String(usb->formatFAT()));
222222
#elif defined(HAS_USB) && defined(HAS_SD)
223223
sd_and_usb();
224224
Serial.println("\t * Formatting SD to FAT:" + String(sd->formatFAT()));

0 commit comments

Comments
 (0)