Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
6fbcacbb
Commit
6fbcacbb
authored
Oct 07, 2003
by
Uwe Bonnes
Committed by
Alexandre Julliard
Oct 07, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
_read(): In _O_TEXT mode make Readfile calls in chunks as big as
possible.
parent
d1fa4b2d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
51 deletions
+60
-51
file.c
dlls/msvcrt/file.c
+60
-51
No files found.
dlls/msvcrt/file.c
View file @
6fbcacbb
...
...
@@ -1164,11 +1164,27 @@ int _rmtmp(void)
}
/*********************************************************************
* (internal) remove_cr
*
* Remove all \r inplace.
* return the number of \r removed
*/
static
unsigned
int
remove_cr
(
char
*
buf
,
unsigned
int
count
)
{
unsigned
int
i
,
j
;
for
(
i
=
0
;
i
<
count
;
i
++
)
if
(
buf
[
i
]
==
'\r'
)
break
;
for
(
j
=
i
+
1
;
j
<
count
;
j
++
)
if
(
buf
[
j
]
!=
'\r'
)
buf
[
i
++
]
=
buf
[
j
];
return
count
-
i
;
}
/*********************************************************************
* _read (MSVCRT.@)
*/
int
_read
(
int
fd
,
void
*
buf
,
unsigned
int
count
)
{
DWORD
num_read
;
DWORD
num_read
,
all_read
=
0
;
char
*
bufstart
=
buf
;
HANDLE
hand
=
msvcrt_fdtoh
(
fd
);
/* Dont trace small reads, it gets *very* annoying */
...
...
@@ -1177,56 +1193,49 @@ int _read(int fd, void *buf, unsigned int count)
if
(
hand
==
INVALID_HANDLE_VALUE
)
return
-
1
;
if
(
MSVCRT_flags
[
fd
]
&
_O_BINARY
)
{
if
(
ReadFile
(
hand
,
buf
,
count
,
&
num_read
,
NULL
))
{
if
(
num_read
!=
count
&&
MSVCRT_files
[
fd
])
{
TRACE
(
":EOF
\n
"
);
MSVCRT_flags
[
fd
]
|=
MSVCRT__IOEOF
;
/*
MSVCRT_files[fd]->_flag |= MSVCRT__IOEOF;
*/
}
TRACE
(
"%s
\n
"
,
debugstr_an
(
buf
,
num_read
));
return
num_read
;
}
TRACE
(
":failed-last error (%ld)
\n
"
,
GetLastError
());
if
(
MSVCRT_files
[
fd
])
MSVCRT_files
[
fd
]
->
_flag
|=
MSVCRT__IOERR
;
return
-
1
;
}
else
{
char
cc
,
*
s
=
(
char
*
)
buf
,
*
buf_start
=
(
char
*
)
buf
;
unsigned
int
i
;
for
(
i
=
0
,
num_read
=
1
;
i
<
count
&&
(
num_read
==
1
);)
{
if
(
ReadFile
(
hand
,
&
cc
,
1
,
&
num_read
,
NULL
))
if
(
num_read
==
1
)
if
((
cc
!=
'\r'
)
||
MSVCRT_flags
[
fd
]
&
_O_BINARY
)
{
*
s
++
=
(
char
)
cc
;
i
++
;
}
}
if
(
num_read
!=
1
)
{
TRACE
(
":EOF
\n
"
);
if
(
MSVCRT_files
[
fd
])
MSVCRT_flags
[
fd
]
|=
MSVCRT__IOEOF
;
/*
MSVCRT_files[fd]->_flag |= MSVCRT__IOEOF;
*/
}
if
(
count
>
4
)
TRACE
(
"%s
\n
"
,
debugstr_an
(
buf_start
,
s
-
buf_start
));
return
s
-
buf_start
;
}
return
0
;
/* Reading single bytes in O_TEXT mode makes things slow
* So read big chunks, then remove the \r in memory and try reading
* the rest until the request is satisfied or EOF is met
*/
while
(
all_read
<
count
)
{
if
(
ReadFile
(
hand
,
bufstart
+
all_read
,
count
-
all_read
,
&
num_read
,
NULL
))
{
if
(
num_read
!=
(
count
-
all_read
))
{
TRACE
(
":EOF
\n
"
);
if
(
MSVCRT_files
[
fd
])
{
MSVCRT_flags
[
fd
]
|=
MSVCRT__IOEOF
;
/*
MSVCRT_files[fd]->_flag |= MSVCRT__IOEOF;
*/
}
if
((
MSVCRT_flags
[
fd
]
&
_O_BINARY
)
!=
_O_BINARY
)
num_read
-=
remove_cr
(
bufstart
+
all_read
,
num_read
);
all_read
+=
num_read
;
if
(
count
>
4
)
TRACE
(
"%s
\n
"
,
debugstr_an
(
buf
,
all_read
));
return
all_read
;
}
if
((
MSVCRT_flags
[
fd
]
&
_O_BINARY
)
!=
_O_BINARY
)
{
num_read
-=
remove_cr
(
bufstart
+
all_read
,
num_read
);
}
all_read
+=
num_read
;
}
else
{
TRACE
(
":failed-last error (%ld)
\n
"
,
GetLastError
());
if
(
MSVCRT_files
[
fd
])
MSVCRT_files
[
fd
]
->
_flag
|=
MSVCRT__IOERR
;
return
-
1
;
}
}
if
(
count
>
4
)
TRACE
(
"%s
\n
"
,
debugstr_an
(
buf
,
all_read
));
return
all_read
;
}
/*********************************************************************
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment