Skip to content

Commit 225a908

Browse files
committed
Added files.rm_f
1 parent c787ab2 commit 225a908

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/bd2k/util/files.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ def mkdir_p( path ):
1414
else:
1515
raise
1616

17+
18+
def rm_f( path ):
19+
"""
20+
Remove the file at the given path with os.remove(), ignoring errors caused by the file's absence.
21+
"""
22+
try:
23+
os.remove( path )
24+
except OSError as e:
25+
if e.errno == errno.ENOENT:
26+
pass
27+
else:
28+
raise
29+
30+
1731
if False:
1832

1933
# These are not needed for Python 2.7 as Python's builtin file object's read() and write()

0 commit comments

Comments
 (0)