LibC: Fix freopen to preserve file state :)
This commit is contained in:
@@ -404,7 +404,8 @@ FILE* freopen(const char* pathname, const char* mode_str, FILE* file)
|
|||||||
|
|
||||||
if (pathname)
|
if (pathname)
|
||||||
{
|
{
|
||||||
fclose(file);
|
fflush(file);
|
||||||
|
close(file->fd);
|
||||||
file->fd = open(pathname, mode, 0666);
|
file->fd = open(pathname, mode, 0666);
|
||||||
file->mode = mode & O_ACCMODE;
|
file->mode = mode & O_ACCMODE;
|
||||||
if (file->fd == -1)
|
if (file->fd == -1)
|
||||||
|
|||||||
Reference in New Issue
Block a user