Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-esp32
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-esp32
Commits
fa9e0590
Unverified
Commit
fa9e0590
authored
Apr 18, 2023
by
Dirk Carstensen
Committed by
GitHub
Apr 18, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getNextFileName: Get info whether filename is a file or directory (#8079)
re-submit #8068
parent
d601c897
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
0 deletions
+38
-0
libraries/FS/src/FS.cpp
libraries/FS/src/FS.cpp
+9
-0
libraries/FS/src/FS.h
libraries/FS/src/FS.h
+1
-0
libraries/FS/src/FSImpl.h
libraries/FS/src/FSImpl.h
+1
-0
libraries/FS/src/vfs_api.cpp
libraries/FS/src/vfs_api.cpp
+26
-0
libraries/FS/src/vfs_api.h
libraries/FS/src/vfs_api.h
+1
-0
No files found.
libraries/FS/src/FS.cpp
View file @
fa9e0590
...
...
@@ -203,6 +203,15 @@ String File::getNextFileName(void)
}
String
File
::
getNextFileName
(
bool
*
isDir
)
{
if
(
!
_p
)
{
return
""
;
}
return
_p
->
getNextFileName
(
isDir
);
}
void
File
::
rewindDirectory
(
void
)
{
if
(
!*
this
)
{
...
...
libraries/FS/src/FS.h
View file @
fa9e0590
...
...
@@ -81,6 +81,7 @@ public:
boolean
seekDir
(
long
position
);
File
openNextFile
(
const
char
*
mode
=
FILE_READ
);
String
getNextFileName
(
void
);
String
getNextFileName
(
boolean
*
isDir
);
void
rewindDirectory
(
void
);
protected:
...
...
libraries/FS/src/FSImpl.h
View file @
fa9e0590
...
...
@@ -45,6 +45,7 @@ public:
virtual
FileImplPtr
openNextFile
(
const
char
*
mode
)
=
0
;
virtual
boolean
seekDir
(
long
position
);
virtual
String
getNextFileName
(
void
);
virtual
String
getNextFileName
(
bool
*
isDir
);
virtual
void
rewindDirectory
(
void
)
=
0
;
virtual
operator
bool
()
=
0
;
};
...
...
libraries/FS/src/vfs_api.cpp
View file @
fa9e0590
...
...
@@ -540,6 +540,32 @@ String VFSFileImpl::getNextFileName()
return
name
;
}
String
VFSFileImpl
::
getNextFileName
(
bool
*
isDir
)
{
if
(
!
_isDirectory
||
!
_d
)
{
return
""
;
}
struct
dirent
*
file
=
readdir
(
_d
);
if
(
file
==
NULL
)
{
return
""
;
}
if
(
file
->
d_type
!=
DT_REG
&&
file
->
d_type
!=
DT_DIR
)
{
return
""
;
}
String
fname
=
String
(
file
->
d_name
);
String
name
=
String
(
_path
);
if
(
!
fname
.
startsWith
(
"/"
)
&&
!
name
.
endsWith
(
"/"
))
{
name
+=
"/"
;
}
name
+=
fname
;
// check entry is a directory
if
(
isDir
)
{
*
isDir
=
(
file
->
d_type
==
DT_DIR
);
}
return
name
;
}
void
VFSFileImpl
::
rewindDirectory
(
void
)
{
if
(
!
_isDirectory
||
!
_d
)
{
...
...
libraries/FS/src/vfs_api.h
View file @
fa9e0590
...
...
@@ -73,6 +73,7 @@ public:
boolean
isDirectory
(
void
)
override
;
boolean
seekDir
(
long
position
)
override
;
String
getNextFileName
(
void
)
override
;
String
getNextFileName
(
bool
*
isDir
)
override
;
FileImplPtr
openNextFile
(
const
char
*
mode
)
override
;
void
rewindDirectory
(
void
)
override
;
operator
bool
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment