DecryptFileName decrypts a file path
(in string)
| 586 | |
| 587 | // DecryptFileName decrypts a file path |
| 588 | func (c *Cipher) DecryptFileName(in string) (string, error) { |
| 589 | if c.mode == NameEncryptionOff { |
| 590 | remainingLength := len(in) - len(c.encryptedSuffix) |
| 591 | if remainingLength == 0 || !strings.HasSuffix(in, c.encryptedSuffix) { |
| 592 | return "", ErrorNotAnEncryptedFile |
| 593 | } |
| 594 | decrypted := in[:remainingLength] |
| 595 | if version.Match(decrypted) { |
| 596 | _, unversioned := version.Remove(decrypted) |
| 597 | if unversioned == "" { |
| 598 | return "", ErrorNotAnEncryptedFile |
| 599 | } |
| 600 | } |
| 601 | // Leave the version string on, if it was there |
| 602 | return decrypted, nil |
| 603 | } |
| 604 | return c.decryptFileName(in) |
| 605 | } |
| 606 | |
| 607 | // DecryptDirName decrypts a directory path |
| 608 | func (c *Cipher) DecryptDirName(in string) (string, error) { |
nothing calls this directly
no test coverage detected