- fs_file_seek(fp, 0, SEEK_END);
- dir.len = fs_file_tell(fp);
- fs_file_seek(fp, 0, SEEK_SET);
+ if (fs_file_seek(fp, 0, FS_FILE_SEEK_END) != 0 || ((len = fs_file_tell(fp)) < 0))
+ goto err;
+ if (fs_file_seek(fp, 0, FS_FILE_SEEK_SET) != 0)
+ goto err;