Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
a86fb74c
Commit
a86fb74c
authored
Oct 03, 2016
by
Arnim Läuger
Committed by
Philip Gladstone
Oct 02, 2016
Browse files
implement file.size for spiffs (#1516)
Another bug squashed!
parent
d96d7f23
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/platform/vfs.h
View file @
a86fb74c
...
...
@@ -85,7 +85,7 @@ inline sint32_t vfs_flush( int fd ) {
// Returns: File size
inline
uint32_t
vfs_size
(
int
fd
)
{
vfs_file
*
f
=
(
vfs_file
*
)
fd
;
return
f
&&
f
->
fns
->
size
?
f
->
fns
->
size
(
f
)
:
0
;
return
f
?
f
->
fns
->
size
(
f
)
:
0
;
}
// vfs_ferrno - get file system specific errno
...
...
app/spiffs/spiffs.c
View file @
a86fb74c
...
...
@@ -243,6 +243,7 @@ static sint32_t myspiffs_vfs_lseek( const struct vfs_file *fd, sint32_t off, int
static
sint32_t
myspiffs_vfs_eof
(
const
struct
vfs_file
*
fd
);
static
sint32_t
myspiffs_vfs_tell
(
const
struct
vfs_file
*
fd
);
static
sint32_t
myspiffs_vfs_flush
(
const
struct
vfs_file
*
fd
);
static
uint32_t
myspiffs_vfs_size
(
const
struct
vfs_file
*
fd
);
static
sint32_t
myspiffs_vfs_ferrno
(
const
struct
vfs_file
*
fd
);
static
sint32_t
myspiffs_vfs_closedir
(
const
struct
vfs_dir
*
dd
);
...
...
@@ -295,7 +296,7 @@ static vfs_file_fns myspiffs_file_fns = {
.
eof
=
myspiffs_vfs_eof
,
.
tell
=
myspiffs_vfs_tell
,
.
flush
=
myspiffs_vfs_flush
,
.
size
=
NULL
,
.
size
=
myspiffs_vfs_size
,
.
ferrno
=
myspiffs_vfs_ferrno
};
...
...
@@ -477,6 +478,16 @@ static sint32_t myspiffs_vfs_flush( const struct vfs_file *fd ) {
return
SPIFFS_fflush
(
&
fs
,
fh
)
>=
0
?
VFS_RES_OK
:
VFS_RES_ERR
;
}
static
uint32_t
myspiffs_vfs_size
(
const
struct
vfs_file
*
fd
)
{
GET_FILE_FH
(
fd
);
int32_t
curpos
=
SPIFFS_tell
(
&
fs
,
fh
);
int32_t
size
=
SPIFFS_lseek
(
&
fs
,
fh
,
0
,
SPIFFS_SEEK_END
);
(
void
)
SPIFFS_lseek
(
&
fs
,
fh
,
curpos
,
SPIFFS_SEEK_SET
);
return
size
;
}
static
sint32_t
myspiffs_vfs_ferrno
(
const
struct
vfs_file
*
fd
)
{
return
SPIFFS_errno
(
&
fs
);
}
...
...
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