// longFilenameSupport adds the necessary prefix to the path to enable long
// filename support on windows if necessary.
// This does NOT check the current system, i.e. will also take effect on unix paths.
978567
func longFilenameSupport(path string) string {
	if filepath.IsAbs(path) && !strings.HasPrefix(path, `\\`) {
		return `\\?\` + path
	}
	return path
}
1125296
func GetTokenizerForFilename(name string) (Tokenizer, error) {
	for _, tokenizer := range tokenizers {
		if matched, err := tokenizer.AcceptsFilename(name); err != nil {
			return nil, err
		} else if matched {
			return tokenizer, nil
		}
	}
	return nil, nil
}
493522
func NewFilePathName(packagePath, packageName string) *File {
	return &File{
		Group: &Group{
			multi: true,
		},
		name:    packageName,
		path:    packagePath,
		imports: map[string]importdef{},
		hints:   map[string]importdef{},
	}
}
839554
func (r *RemoteStatus) ExtraFileName() string {
	r.Lock()
	defer r.Unlock()

	if r.extraFileName == "" || time.Since(r.failingSince) < failureDisplayThreshold {
		return ""
	}

	return r.extraFileName
}
67502
func GetDisplayFilename(filename string) string {
	if absName, err := filepath.Abs(filename); err == nil {
		return absName
	}

	return filename
}
923447
func (c *downloadCommand) ResolveFilename() string {
	filename := c.Filename
	if filename == "" {
		filename = backups.FilenamePrefix + c.ID + ".tar.gz"
	}
	return filename
}
297936
func isSupported(path string) bool {
	suppPath := filepath.Join(runtime.GOOS, runtime.GOARCH) + string(filepath.Separator)
	return path == suppPath
}
48193
func trimPath(filename string) string {
	for _, prefix := range trimPaths {
		if trimmed := strings.TrimPrefix(filename, prefix); len(trimmed) < len(filename) {
			return trimmed
		}
	}
	return filename
}
18935
func (ss *superset) FileNameString() string {
	v := ss.FileName
	if v == "" {
		v = stringFromMixedArray(ss.FileNameBytes)
	}
	if v != "" {
		if strings.Contains(v, "/") {
			// Bogus schema blob; ignore.
			return ""
		}
		if strings.Contains(v, "\\") {
			// Bogus schema blob; ignore.
			return ""
		}
	}
	return v
}
1347274
func FilenameCompleter(query, ctx string) []string {
	var compls []string
	var c *C.char
	q := C.CString(query)

	for i := 0; ; i++ {
		if c = C.rl_filename_completion_function(q, C.int(i)); c == nil {
			break
		}
		compls = append(compls, C.GoString(c))
		C.free(unsafe.Pointer(c))
	}

	C.free(unsafe.Pointer(q))

	return compls
}
920106
func (p *ApplicationCredentialsProvider) filename() (string, error) {
	if p.Filename == "" {
		if p.Filename = os.Getenv("GOOGLE_APPLICATION_CREDENTIALS"); p.Filename == "" {
			return "", fmt.Errorf("Unable to read GOOGLE_APPLICATION_CREDENTIALS")
		}
	}
	return p.Filename, nil
}
159861
func (c *CommitFile) GetFilename() string {
	if c == nil || c.Filename == nil {
		return ""
	}
	return *c.Filename
}
1328285
func DefaultParseFileName(name string) (int, int, error) {
	base := filepath.Base(name)
	idx := strings.Index(base, ".")
	if idx == -1 {
		return 0, 0, fmt.Errorf("file %s is named incorrectly", name)
	}

	id := base[:idx]

	idx = strings.Index(id, "-")
	if idx == -1 {
		return 0, 0, fmt.Errorf("file %s is named incorrectly", name)
	}

	generation, err := strconv.ParseUint(id[:idx], 10, 64)
	if err != nil {
		return 0, 0, fmt.Errorf("file %s is named incorrectly", name)
	}

	sequence, err := strconv.ParseUint(id[idx+1:], 10, 32)
	if err != nil {
		return 0, 0, fmt.Errorf("file %s is named incorrectly", name)
	}

	return int(generation), int(sequence), nil
}
230710
func StatsFilename(tsmPath string) string {
	if strings.HasSuffix(tsmPath, "."+TmpTSMFileExtension) {
		tsmPath = strings.TrimSuffix(tsmPath, "."+TmpTSMFileExtension)
	}
	if strings.HasSuffix(tsmPath, "."+TSMFileExtension) {
		tsmPath = strings.TrimSuffix(tsmPath, "."+TSMFileExtension)
	}
	return tsmPath + "." + TSSFileExtension
}
1052819
func MakeCPUProfileFilename(dir string, start time.Time, duration time.Duration) string {
	return makeProfileFilename(cpuProfilePrefix, dir, start, duration)
}
1350157
func GetLongPathName(path string) (string, error) {
	// See https://groups.google.com/forum/#!topic/golang-dev/1tufzkruoTg
	p := syscall.StringToUTF16(path)
	b := p // GetLongPathName says we can reuse buffer
	n, err := syscall.GetLongPathName(&p[0], &b[0], uint32(len(b)))
	if err != nil {
		return "", err
	}
	if n > uint32(len(b)) {
		b = make([]uint16, n)
		_, err = syscall.GetLongPathName(&p[0], &b[0], uint32(len(b)))
		if err != nil {
			return "", err
		}
	}
	return syscall.UTF16ToString(b), nil
}
1227202
func fileBaseName(p string) string {
	return strings.TrimSuffix(filepath.Base(p), filepath.Ext(p))
}