blob: ec1c1e03c4f03306ac02a3df9c0ec88b6cab77e8 [file] [log] [blame]
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package util
import (
"os"
"path/filepath"
)
func GetHostOutDirectory() (string, error) {
executablePath, err := os.Executable()
if err != nil {
return "", err
}
dir, err := filepath.Abs(filepath.Dir(executablePath))
if err != nil {
return "", err
}
parent, filePart := filepath.Split(dir)
if filePart == "host-tools" {
// We're running at desk and actually need the host_x64 directory instead.
return filepath.Join(parent, "host_x64"), nil
}
return dir, nil
}
func GetHostToolsDirectory() (string, error) {
hostOut, err := GetHostOutDirectory()
if err != nil {
return "", err
}
parent, _ := filepath.Split(hostOut)
return filepath.Join(parent, "host-tools"), nil
}