Remove a file or directory (or a directory tree if rec=1). if ignore_errors is True, errors while removing directories will be ignored.
(self, rec=1, ignore_errors=False)
| 594 | return error.checked_call(os.path.samefile, self.strpath, other) |
| 595 | |
| 596 | def remove(self, rec=1, ignore_errors=False): |
| 597 | class="st">"""Remove a file or directory (or a directory tree if rec=1). |
| 598 | if ignore_errors is True, errors while removing directories will |
| 599 | be ignored. |
| 600 | class="st">""" |
| 601 | if self.check(dir=1, link=0): |
| 602 | if rec: |
| 603 | class="cm"># force remove of readonly files on windows |
| 604 | if iswin32: |
| 605 | self.chmod(0o700, rec=1) |
| 606 | import shutil |
| 607 | |
| 608 | error.checked_call( |
| 609 | shutil.rmtree, self.strpath, ignore_errors=ignore_errors |
| 610 | ) |
| 611 | else: |
| 612 | error.checked_call(os.rmdir, self.strpath) |
| 613 | else: |
| 614 | if iswin32: |
| 615 | self.chmod(0o700) |
| 616 | error.checked_call(os.remove, self.strpath) |
| 617 | |
| 618 | def computehash(self, hashtype=class="st">"md5", chunksize=524288): |
| 619 | class="st">""class="st">"Return hexdigest of hashvalue for this file."class="st">"" |