// OutputFile returns the absolute filename of the SingleAsset.Output. // It also add a suffix in the basename (for example an md5 hash or a version number). // The suffix is inserted just before the file extension and at the end of the filename // if no extension was found. func (sa SingleAsset) OutputFile(suffix string) (string, error) { out, err := filepath.Abs(sa.Output) if err != nil { return "", err } return helpers.AddFileSuffix(out, suffix), nil }
// OutputFile returns the absolute filename of an output based on the filename of the input. // It also add a suffix in the basename (for example an md5 hash or a version number). // The suffix is inserted just before the file extension and at the end of the filename // if no extension was found. func (ap AssetPack) OutputFile(filename string, suffix string) (string, error) { filename, err := filepath.Abs(filename) if err != nil { return "", err } input, err := filepath.Abs(ap.Input) if err != nil { return "", err } if !strings.HasPrefix(filename, input) { return "", errors.New(ap.Input + " is not a prefix of " + filename) } out := bytes.NewBuffer(nil) out.WriteString(ap.Output) out.WriteByte(os.PathSeparator) out.WriteString(filename[len(input):]) return helpers.AddFileSuffix(out.String(), suffix), nil }