prepare API for shorname

Fix filename for esp8266
This commit is contained in:
Luc 2019-10-16 17:24:48 +02:00
parent bead8ba2d8
commit bd026eabe9
4 changed files with 26 additions and 5 deletions

View File

@ -41,6 +41,7 @@ public:
operator bool() const;
bool isDirectory();
const char* name() const;
const char* shortname() const;
const char* filename() const;
void close();
bool isOpen();

View File

@ -336,6 +336,12 @@ ESP_SDFile ESP_SDFile::openNextFile()
return ESP_SDFile();
}
//TODO need to find reliable way
const char* ESP_SDFile::shortname() const
{
return _name.c_str();
}
const char * ESP_SD::FilesystemName()
{
return "SD native";

View File

@ -244,9 +244,9 @@ ESP_SDFile::ESP_SDFile(void* handle, bool isdir, bool iswritemode, const char *
//filename
char tmp[255];
tSDFile_handle[i].getName(tmp,254);
_filename = tmp;
_filename = path;
//name
_name = _filename;
_name = tmp;
if (_name.endsWith("/")) {
_name.remove( _name.length() - 1,1);
_isfakedir = true;
@ -272,6 +272,13 @@ ESP_SDFile::ESP_SDFile(void* handle, bool isdir, bool iswritemode, const char *
}
}
const char* ESP_SDFile::shortname() const
{
//static char shorname[13];
//entry.getSFN(tmps);
return _filename.c_str();
}
void ESP_SDFile::close()
{
if (_index != -1) {
@ -303,12 +310,13 @@ ESP_SDFile ESP_SDFile::openNextFile()
}
sdfat::File tmp = tSDFile_handle[_index].openNextFile();
if (tmp){
#if defined(ESP_DEBUG_FEATURE)
char tmps[255];
tmp.getName(tmps,254);
log_esp3d("tmp name :%s %s", tmps, (tmp.isDir())?"isDir":"isFile");
#endif //ESP_DEBUG_FEATURE
ESP_SDFile esptmp(&tmp, tmp.isDir());
String s = _filename ;
if (s!="/")s+="/";
s += tmps;
ESP_SDFile esptmp(&tmp, tmp.isDir(),false, s.c_str());
esptmp.close();
return esptmp;
}

View File

@ -330,5 +330,11 @@ const char * ESP_SD::FilesystemName()
return "SDIO";
}
//TODO need to find reliable way
const char* ESP_SDFile::shortname() const
{
return _name.c_str();
}
#endif //SD_DEVICE == ESP_SDIO
#endif //ARCH_ESP32 && SD_DEVICE