(fp string, directory bool)
| 1680 | } |
| 1681 | |
| 1682 | func (project *Project) PathToAbsolute(fp string, directory bool) string { |
| 1683 | |
| 1684 | if filepath.IsAbs(fp) || strings.TrimSpace(fp) == "" { |
| 1685 | return fp |
| 1686 | } |
| 1687 | elements := []string{filepath.Dir(project.Filepath), filepath.FromSlash(string(fp))} |
| 1688 | final := filepath.Clean(filepath.Join(elements...)) |
| 1689 | |
| 1690 | var exists bool |
| 1691 | if directory { |
| 1692 | exists = FolderExists(final) |
| 1693 | } else { |
| 1694 | exists = FileExists(final) |
| 1695 | } |
| 1696 | |
| 1697 | // if !exists { |
| 1698 | // elements = []string{filepath.Dir(LocalRelativePath("")), filepath.FromSlash(string(fp))} // TODO: REMOVE THIS AT SOME POINT IN THE FUTURE, AS THIS SERVES TO FIX A TEMPORARY BLUNDER CAUSED BY MAKING PATHS RELATIVE TO THE MASTERPLAN FOLDER |
| 1699 | // final = filepath.Clean(filepath.Join(elements...)) |
| 1700 | // } |
| 1701 | // If the file doesn't exist, we'll just abandon our efforts; maybe it's a URL, for example. |
| 1702 | if !exists { |
| 1703 | return fp |
| 1704 | } |
| 1705 | return final |
| 1706 | } |
no test coverage detected