Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
François Revol
firmware
Commits
d4a24d51
Commit
d4a24d51
authored
Jul 29, 2019
by
q3k
Committed by
Rahix
Jul 29, 2019
Browse files
feat(fatfs): Add seek and tell implementation
parent
79ec7d37
Changes
2
Hide whitespace changes
Inline
Side-by-side
epicardium/epicardium.h
View file @
d4a24d51
...
...
@@ -54,8 +54,8 @@ typedef unsigned int size_t;
#define API_FILE_READ 0x32
#define API_FILE_WRITE 0x34
#define API_FILE_FLUSH 0x35
#define API_FILE_SEEK 0x36
//NYI
#define API_FILE_TELL 0x37
//NYI
#define API_FILE_SEEK 0x36
#define API_FILE_TELL 0x37
#define API_FILE_STAT 0x38
/* clang-format on */
...
...
@@ -483,6 +483,12 @@ API(
/** */
API
(
API_FILE_FLUSH
,
int
epic_file_flush
(
int
fd
));
/** */
API
(
API_FILE_SEEK
,
int
epic_file_seek
(
int
fd
,
long
offset
,
int
whence
));
/** */
API
(
API_FILE_TELL
,
int
epic_file_tell
(
int
fd
));
/** */
enum
epic_stat_type
{
/** */
...
...
epicardium/modules/fatfs.c
View file @
d4a24d51
...
...
@@ -326,6 +326,43 @@ int epic_file_flush(int fd)
return
0
;
}
int
epic_file_seek
(
int
fd
,
long
offset
,
int
whence
)
{
int
res
;
struct
FatObject
*
o
;
res
=
get_fat_object
(
fd
,
FO_File
,
&
o
);
if
(
res
)
{
return
-
res
;
}
switch
(
whence
)
{
case
SEEK_SET
:
res
=
f_lseek
(
&
o
->
file
,
offset
);
return
-
fresult_to_errno_table
[
res
];
case
SEEK_CUR
:
res
=
f_lseek
(
&
o
->
file
,
f_tell
(
&
o
->
file
)
+
offset
);
return
-
fresult_to_errno_table
[
res
];
case
SEEK_END
:
res
=
f_lseek
(
&
o
->
file
,
f_size
(
&
o
->
file
)
+
offset
);
return
-
fresult_to_errno_table
[
res
];
default:
return
-
EINVAL
;
}
return
0
;
}
int
epic_file_tell
(
int
fd
)
{
int
res
;
struct
FatObject
*
o
;
res
=
get_fat_object
(
fd
,
FO_File
,
&
o
);
if
(
res
)
{
return
-
1
;
}
return
f_tell
(
&
o
->
file
);
}
int
epic_file_stat
(
const
char
*
filename
,
epic_stat_t
*
stat
)
{
int
res
;
...
...
Write
Preview
Supports
Markdown
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