case FILE_FLAG_MODE_APPEND:\r
_SysSeek(fp->FD, fp->BufferOfs, SEEK_SET);\r
len = _SysWrite(fp->FD, fp->Buffer, fp->BufferPos);\r
- if( len < fp->BufferPos )\r
+ if( len != fp->BufferPos )\r
ret = 1;\r
- fp->BufferPos -= len;\r
+ if( len <= fp->BufferPos )\r
+ {\r
+ fp->BufferPos -= len;\r
+ }\r
fp->BufferOfs = _SysTell(fp->FD);\r
break;\r
\r
len = _SysWrite(fp->FD, fp->Buffer, fp->BufferPos);\r
if( len != fp->BufferPos )\r
ret = 1;\r
- fp->BufferPos -= len;\r
+ if( len <= fp->BufferPos )\r
+ {\r
+ fp->BufferPos -= len;\r
+ }\r
+ //else {\r
+ // _SysDebug("Flush of %i failed, %s", fp->FD, strerror(errno));\r
+ //}\r
break;\r
default:\r
break;\r