(fp string, directory bool)
| 1659 | } |
| 1660 | |
| 1661 | func (project *Project) PathToRelative(fp string, directory bool) string { |
| 1662 | |
| 1663 | var exists bool |
| 1664 | if directory { |
| 1665 | exists = FolderExists(fp) |
| 1666 | } else { |
| 1667 | exists = FileExists(fp) |
| 1668 | } |
| 1669 | |
| 1670 | if !filepath.IsAbs(fp) || strings.TrimSpace(fp) == "" || !exists { |
| 1671 | return fp |
| 1672 | } |
| 1673 | rel, err := filepath.Rel(filepath.Dir(project.Filepath), string(fp)) |
| 1674 | // We don't do anything if the path could not be made relative; a possibility is that it's not possible (on Windows, for example, there is no way to get |
| 1675 | // a relative path from C:\ to D:\. They're two different drives. There is no relative path that works here.) |
| 1676 | if err != nil { |
| 1677 | return fp |
| 1678 | } |
| 1679 | return filepath.ToSlash(rel) |
| 1680 | } |
| 1681 | |
| 1682 | func (project *Project) PathToAbsolute(fp string, directory bool) string { |
| 1683 |
no test coverage detected