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:
parent
cd79fe5f31
commit
aec735eecd
@ -1792,10 +1792,11 @@ STATIC int shrink_file(f_node_ptr fnp)
|
|||||||
struct dpb FAR *dpbp = fnp->f_dpb;
|
struct dpb FAR *dpbp = fnp->f_dpb;
|
||||||
int ret = DE_ACCESS;
|
int ret = DE_ACCESS;
|
||||||
|
|
||||||
fnp->f_offset = fnp->f_dir.dir_size; /* end of file */
|
|
||||||
|
|
||||||
if (fnp->f_offset)
|
if (fnp->f_offset)
|
||||||
fnp->f_offset--; /* last existing cluster */
|
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 */
|
if (map_cluster(fnp, XFR_READ) != SUCCESS) /* error, don't truncate */
|
||||||
goto done;
|
goto done;
|
||||||
|
Loading…
Reference in New Issue
Block a user