Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ef55ee02
Commit
ef55ee02
authored
Jul 12, 2000
by
Greg Stein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apply patch #100868 from Moshe Zadka:
refactor the copying of file data. new: shutil.copyfileobj(fsrc, fdst)
parent
03a873a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
Lib/shutil.py
Lib/shutil.py
+10
-5
No files found.
Lib/shutil.py
View file @
ef55ee02
...
...
@@ -9,6 +9,15 @@ import sys
import
stat
def
copyfileobj
(
fsrc
,
fdst
,
length
=
16
*
1024
):
"""copy data from file-like object fsrc to file-like object fdst"""
while
1
:
buf
=
fsrc
.
read
(
length
)
if
not
buf
:
break
fdst
.
write
(
buf
)
def
copyfile
(
src
,
dst
):
"""Copy data from src to dst"""
fsrc
=
None
...
...
@@ -16,11 +25,7 @@ def copyfile(src, dst):
try
:
fsrc
=
open
(
src
,
'rb'
)
fdst
=
open
(
dst
,
'wb'
)
while
1
:
buf
=
fsrc
.
read
(
16
*
1024
)
if
not
buf
:
break
fdst
.
write
(
buf
)
copyfileobj
(
fsrc
,
fdst
)
finally
:
if
fdst
:
fdst
.
close
()
...
...
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