Another fix for file system issues when encountering disk full (like when recording)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15920 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
10d0344e29
commit
eb947cdde1
4 changed files with 35 additions and 3 deletions
|
@ -2329,6 +2329,9 @@ static bool on_start_file(struct enc_file_event_data *data)
|
|||
|
||||
static bool on_end_file(struct enc_file_event_data *data)
|
||||
{
|
||||
if (data->rec_file < 0)
|
||||
return false; /* file already closed, nothing more we can do */
|
||||
|
||||
/* always _try_ to write the file header, even on error */
|
||||
if (ci->close(data->rec_file) != 0)
|
||||
return false;
|
||||
|
|
|
@ -144,10 +144,12 @@ static bool on_end_file(struct enc_file_event_data *data)
|
|||
struct riff_header hdr;
|
||||
uint32_t data_size;
|
||||
|
||||
/* always _try_ to write the file header, even on error */
|
||||
if (data->rec_file < 0)
|
||||
return false; /* file already closed, nothing more we can do */
|
||||
|
||||
if (ci->lseek(data->rec_file, 0, SEEK_SET) != 0 ||
|
||||
ci->read(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr))
|
||||
/* always _try_ to write the file header, even on error */
|
||||
if ((ci->lseek(data->rec_file, 0, SEEK_SET)) ||
|
||||
(ci->read(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -257,6 +257,9 @@ static bool on_end_file(struct enc_file_event_data *data)
|
|||
|
||||
uint32_t data_size;
|
||||
|
||||
if (data->rec_file < 0)
|
||||
return false; /* file already closed, nothing more we can do */
|
||||
|
||||
/* always _try_ to write the file header, even on error */
|
||||
|
||||
/* read template headers at start */
|
||||
|
|
|
@ -548,6 +548,14 @@ static int readwrite(int fd, void* buf, long count, bool write)
|
|||
file->fileoffset += nread;
|
||||
}
|
||||
file->cacheoffset = -1;
|
||||
/* adjust file size to length written */
|
||||
if ( write && file->fileoffset > file->size )
|
||||
{
|
||||
file->size = file->fileoffset;
|
||||
#ifdef HAVE_DIRCACHE
|
||||
dircache_update_filesize(fd, file->size, file->fatfile.firstcluster);
|
||||
#endif
|
||||
}
|
||||
return nread ? nread : rc * 10 - 4;
|
||||
}
|
||||
else {
|
||||
|
@ -580,6 +588,14 @@ static int readwrite(int fd, void* buf, long count, bool write)
|
|||
errno = EIO;
|
||||
file->fileoffset += nread;
|
||||
file->cacheoffset = -1;
|
||||
/* adjust file size to length written */
|
||||
if ( file->fileoffset > file->size )
|
||||
{
|
||||
file->size = file->fileoffset;
|
||||
#ifdef HAVE_DIRCACHE
|
||||
dircache_update_filesize(fd, file->size, file->fatfile.firstcluster);
|
||||
#endif
|
||||
}
|
||||
return nread ? nread : rc * 10 - 5;
|
||||
}
|
||||
/* seek back one sector to put file position right */
|
||||
|
@ -591,6 +607,14 @@ static int readwrite(int fd, void* buf, long count, bool write)
|
|||
errno = EIO;
|
||||
file->fileoffset += nread;
|
||||
file->cacheoffset = -1;
|
||||
/* adjust file size to length written */
|
||||
if ( file->fileoffset > file->size )
|
||||
{
|
||||
file->size = file->fileoffset;
|
||||
#ifdef HAVE_DIRCACHE
|
||||
dircache_update_filesize(fd, file->size, file->fatfile.firstcluster);
|
||||
#endif
|
||||
}
|
||||
return nread ? nread : rc * 10 - 6;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue