|
|
|
|
431
|
|
431
|
|
432
|
// openSourceFile opens a source file from a name encoded in a
|
432
|
// openSourceFile opens a source file from a name encoded in a
|
433
|
// profile. File names in a profile after often relative paths, so
|
433
|
// profile. File names in a profile after often relative paths, so
|
434
|
-// search them in each of the paths in sourcePath (or CWD by default),
|
|
|
|
|
434
|
+// search them in each of the paths in searchPath (or CWD by default),
|
435
|
// and their parents.
|
435
|
// and their parents.
|
436
|
-func openSourceFile(path string, sourcePath string) (*os.File, string, error) {
|
|
|
|
|
436
|
+func openSourceFile(path, searchPath string) (*os.File, string, error) {
|
437
|
path = trimPath(path)
|
437
|
path = trimPath(path)
|
438
|
|
438
|
|
439
|
if filepath.IsAbs(path) {
|
439
|
if filepath.IsAbs(path) {
|
|
|
|
|
442
|
}
|
442
|
}
|
443
|
|
443
|
|
444
|
// Scan each component of the path
|
444
|
// Scan each component of the path
|
445
|
- for _, dir := range strings.Split(sourcePath, ":") {
|
|
|
|
|
445
|
+ for _, dir := range strings.Split(searchPath, ":") {
|
446
|
// Search up for every parent of each possible path.
|
446
|
// Search up for every parent of each possible path.
|
447
|
for {
|
447
|
for {
|
448
|
filename := filepath.Join(dir, path)
|
448
|
filename := filepath.Join(dir, path)
|
|
|
|
|
457
|
}
|
457
|
}
|
458
|
}
|
458
|
}
|
459
|
|
459
|
|
460
|
- return nil, "", fmt.Errorf("Could not find file %s on path %s", path, sourcePath)
|
|
|
|
|
460
|
+ return nil, "", fmt.Errorf("Could not find file %s on path %s", path, searchPath)
|
461
|
}
|
461
|
}
|
462
|
|
462
|
|
463
|
// trimPath cleans up a path by removing prefixes that are commonly
|
463
|
// trimPath cleans up a path by removing prefixes that are commonly
|