(name, length)
| 538 | |
| 539 | |
| 540 | def truncate(name, length): |
| 541 | max_trunc = len(name) / 2 |
| 542 | if length > max_trunc: |
| 543 | raise OSError("File name too long") |
| 544 | |
| 545 | trunc = int((len(name) - length) / 3) |
| 546 | return "%s~%s" % (name[:trunc * 2], name[-trunc:]) |
| 547 | |
| 548 | |
| 549 | if sys.getfilesystemencoding().startswith('ANSI'): |