Truncating a 0-byte file should not fail!

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1609 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2011-05-09 01:54:48 +00:00
parent cd79fe5f31
commit aec735eecd

View File

@ -1792,10 +1792,11 @@ STATIC int shrink_file(f_node_ptr fnp)
struct dpb FAR *dpbp = fnp->f_dpb;
int ret = DE_ACCESS;
fnp->f_offset = fnp->f_dir.dir_size; /* end of file */
if (fnp->f_offset)
fnp->f_offset--; /* last existing cluster */
else if (fnp->f_cluster == FREE)
/* zero offset, 0-byte file: nothing to do ! */
goto done_success;
if (map_cluster(fnp, XFR_READ) != SUCCESS) /* error, don't truncate */
goto done;