- Timestamp:
- 10/14/08 19:39:48 (1 month ago)
- Files:
-
- 1 modified
-
Whitix/branches/keobject/user/libc/stdio/file.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Whitix/branches/keobject/user/libc/stdio/file.c
r910 r1135 248 248 int fseek(FILE* stream,long offset,int whence) 249 249 { 250 long pos; 251 250 252 if (!stream) 251 return 0; 252 253 int position=SysSeek(stream->fd,offset,whence); 254 255 if (position >= 0) 256 { 257 stream->position=position; 253 return -1; 254 255 stream->flags &= ~FILE_EOF; 256 257 if (stream->buf && !(stream->flags & _IONBF)) 258 { 259 pos = ftell(stream); 260 261 if (whence == SEEK_CUR) 262 { 263 offset += pos; 264 whence = SEEK_SET; 265 } 266 267 if (whence == SEEK_SET && pos-offset <= stream->ptr - stream->buf && offset-pos <= stream->count) 268 { 269 stream->ptr += offset-pos; 270 stream->count += pos-offset; 271 272 stream->position = offset; 273 274 return 0; 275 } 276 } 277 278 pos = SysSeek(stream->fd,offset,whence); 279 280 if (pos >= 0) 281 { 282 stream->position=pos; 258 283 stream->count=0; /* Force fread to re-read buffer. */ 284 stream->ptr = stream->buf; 259 285 }else{ 260 errno=-pos ition;286 errno=-pos; 261 287 stream->flags |= FILE_ERROR; 262 return 1;288 return -1; 263 289 } 264 290 … … 402 428 size_t fwrite_unlocked(const void* ptr, size_t size, size_t n, FILE* stream) 403 429 { 404 printf("fwrite_unlocked\n"); 405 return 0; 430 return fwrite(ptr, size, n, stream); 406 431 } 407 432
