Comments (5)
There is more than one directory entry for each file with a long file name. The only reliable way to get the correct index is to open the file by path and save the index.
The short file name entry is used to open the file. It is the last entry in the group. You must have the index of the first entry in the group to get the file name.
There can be isolated empty directory entries that can't be used for any lFN file.
So don't expect open by index to work if you an index other than to one returned by open by path.
from sdfat-beta.
Open by index on SdFat-beta opens the SFN directory entry and does not determine the LFN offset.
I will modify open by index to set the LFN offset.
from sdfat-beta.
I was just finishing this up when I saw you posted another reply. I still wanted to show you how I was using open by index.
Here is a better example of how I'm using open by index. The reason I use it this way is I'm displaying a scrollable directory listing and sometimes the directories have 100s of files. Since the memory is limited, keeping the index for the "top" of the list is much easier and I don't have the performance hit of parsing the entire directory multiple times.
You can change the library and the USE_SD_BETA define. teensy 3.6.
Code:
#include "SdFat.h"
#define USE_SD_BETA 0
#if USE_SD_BETA
#define SD_CONFIG SdSpiConfig(SDCARD_SS_PIN, DEDICATED_SPI)
SdFat sd;
#else
SdFatSdio sd;
#endif
File dir;
File file;
char n[512];
void setup() {
Serial.begin(9600);
while (!Serial) SysCall::yield();
Serial.println("Type any character to start");
while (!Serial.available()) SysCall::yield();
#if USE_SD_BETA
if (!sd.begin(SD_CONFIG)) sd.initErrorHalt(&Serial);
#else
if (!sd.begin()) sd.initErrorHalt(&Serial);
#endif
if (!dir.open("/testdir")) Serial.println("dir.open failed");
Serial.println("\n-- openNext --");
while (file.openNext(&dir, O_RDONLY) ) {
if(file.isHidden()==false) {
file.getName(n, 512);
Serial.printf("[%s]\n", n);
}
file.close();
}
Serial.println("\n-- open by index --");
for(int i=0; i<25; i++) {
if(file.open(&dir, i, O_RDONLY) && file.isHidden()==false) {
file.getName(n, 512);
Serial.printf("[%s]\n", n);
}
file.close();
}
}
void loop() {
}
Using SdFat:
-- openNext --
[With.Two dots.txt]
[A long name can be 255 characters.txt]
[lower.txt]
[MIXCASE.txt]
[mixed.TXT]
[Not_8_3.txt]
[OK%83.TXT]
[STD_8_3.TXT]
[With Blank.txt]
[sub folder]
-- open by index --
[With.Two dots.txt]
[A long name can be 255 characters.txt]
[lower.txt]
[MIXCASE.txt]
[mixed.TXT]
[Not_8_3.txt]
[OK%83.TXT]
[STD_8_3.TXT]
[With Blank.txt]
[sub folder]
Using SdFat-beta:
-- openNext --
[With.Two dots.txt]
[A long name can be 255 characters.txt]
[lower.txt]
[MIXCASE.txt]
[mixed.TXT]
[Not_8_3.txt]
[OK%83.TXT]
[STD_8_3.TXT]
[With Blank.txt]
[sub folder]
-- open by index --
[WITHTW~1.TXT]
[ALONGN~1.TXT]
[lower.txt]
[MIXCASE.txt]
[mixed.TXT]
[NOT_8_3.TXT]
[OK%83.TXT]
[STD_8_3.TXT]
[WITHBL~1.TXT]
[SUBFOL~1]
from sdfat-beta.
Try the latest version. getName should work for LFN files opened by index.
from sdfat-beta.
The latest version is working well:
-- open by index --
[With.Two dots.txt]
[A long name can be 255 characters.txt]
[lower.txt]
[MIXCASE.txt]
[mixed.TXT]
[Not_8_3.txt]
[OK%83.TXT]
[STD_8_3.TXT]
[With Blank.txt]
[sub folder]
Thanks so much for the quick fix!
from sdfat-beta.
Related Issues (20)
- hosting the documentation on a github.io page HOT 2
- SD card error with beta version HOT 7
- .h files in separate directories not found HOT 1
- PlatformIO compatibility HOT 1
- ESP32, Multiple cards, and Software Serial questions HOT 13
- SPI access to external SD Card other than normal SPI Pins (not soft spi) HOT 10
- lfnGetName might not properly null terminate callerstring HOT 7
- Moving cursor position with O_APPEND HOT 1
- Support for Multiple Partitions HOT 2
- FsVolume support partition? Also maybe memory leaks HOT 9
- Maybe support __has_include for configuration for sketch or library override of configuration. HOT 5
- Warning "'next' may be used uninitialized in this function" HOT 3
- Conflict between SdFat-beta library and USBFat library
- cannot open File with UTF-8 Name HOT 1
- Any attempt to have Web SD file Downloader
- ESP32 check sd format HOT 6
- SD Card hot swap HOT 1
- 'SdFat {aka class SdFs}' has no member named 'vwd' HOT 7
- SDIO multi-sector read timings HOT 2
- Some SDCard Samples work others not ,SdFat Lib HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdfat-beta.