ParseFileID reads the file id out of a filename.
(name string)
| 680 | |
| 681 | // ParseFileID reads the file id out of a filename. |
| 682 | func ParseFileID(name string) (uint64, bool) { |
| 683 | name = path.Base(name) |
| 684 | if !strings.HasSuffix(name, fileSuffix) { |
| 685 | return 0, false |
| 686 | } |
| 687 | // suffix := name[len(fileSuffix):] |
| 688 | name = strings.TrimSuffix(name, fileSuffix) |
| 689 | id, err := strconv.Atoi(name) |
| 690 | if err != nil { |
| 691 | return 0, false |
| 692 | } |
| 693 | y.AssertTrue(id >= 0) |
| 694 | return uint64(id), true |
| 695 | } |
| 696 | |
| 697 | // IDToFilename does the inverse of ParseFileID |
| 698 | func IDToFilename(id uint64) string { |
no test coverage detected
searching dependent graphs…