// GetFileNode returns a file node
507498
func (p Path) GetFileNode(ctx context.Context, config libkbfs.Config) (libkbfs.Node, error) {
	n, de, err := p.GetNode(ctx, config)
	if err != nil {
		return nil, err
	}

	// TODO: What to do with symlinks?

	if de.Type != data.File && de.Type != data.Exec {
		return nil, fmt.Errorf("openFile: %s is not a file, but a %s", p, de.Type)
	}

	return n, nil
}
1367550
func (c *Client) GetFileInfoByID(id string) (*FileInfo, error) {
	res, err := c.doRequest("b2_get_file_info", map[string]interface{}{
		"fileId": id,
	})
	if err != nil {
		return nil, err
	}
	defer drainAndClose(res.Body)
	var fi *fileInfoObj
	if err := json.NewDecoder(res.Body).Decode(&fi); err != nil {
		return nil, err
	}
	return fi.makeFileInfo(), nil
}
530257
func (net *Network) GetRandomDownNode(excludeIDs ...enode.ID) *Node {
	net.lock.RLock()
	defer net.lock.RUnlock()
	return net.getRandomNode(net.getDownNodeIDs(), excludeIDs)
}
1151489
func (d *Dir) GetByPath(nodePath string) (os.FileInfo, error) {
	var currentNode os.FileInfo = d
	if nodePath == "." || nodePath == "./" {
		return currentNode, nil
	}
	pathNodes := strings.Split(path.Clean(nodePath), "/")
	for _, nodeName := range pathNodes {
		if currentNode.IsDir() != true {
			return nil, fmt.Errorf("Node by name " + currentNode.Name() + " must be dir to get sub node (path " + nodePath + " )")
		}
		var dir = currentNode.(*Dir)
		newNode, err := dir.GetNode(nodeName)
		if err != nil {
			return nil, err
		}
		currentNode = newNode
	}
	return currentNode, nil
}
760343
func GetFileInfo(
	ctx context.Context, config libkbfs.Config, dir libkbfs.Node, name string) (
	data []byte, t time.Time, err error) {
	node, ei, err := config.KBFSOps().Lookup(ctx, dir, name)
	if err != nil {
		return nil, time.Time{}, err
	}
	nmd, err := config.KBFSOps().GetNodeMetadata(ctx, node)
	if err != nil {
		return nil, time.Time{}, err
	}
	data, err = PrettyJSON(fileInfoFile{nmd, ei.PrevRevisions})
	if err != nil {
		return nil, time.Time{}, err
	}
	return data, time.Unix(0, ei.Mtime), nil
}
579569
func (s *GetFileOutput) SetFileMode(v string) *GetFileOutput {
	s.FileMode = &v
	return s
}
548386
func (p Path) GetDirNode(ctx context.Context, config libkbfs.Config) (libkbfs.Node, error) {
	// TODO: Handle non-TLFPathTypes.

	n, de, err := p.GetNode(ctx, config)
	if err != nil {
		return nil, err
	}

	// TODO: What to do with symlinks?

	if de.Type != data.Dir {
		return nil, fmt.Errorf("openDir: %s is not a dir, but a %s", p, de.Type)
	}

	return n, nil
}
509747
func GetFileInfo(path string) (os.FileInfo, error) {
	f, err := os.Open(path)
	if err != nil {
		return nil, err
	}
	defer f.Close()
	return f.Stat()
}
1261830
func (s *PutFileInput) SetFileMode(v string) *PutFileInput {
	s.FileMode = &v
	return s
}
1345757
func (c *tableCache) findNode(fileNum uint64) *tableCacheNode {
	c.mu.Lock()
	defer c.mu.Unlock()

	n := c.nodes[fileNum]
	if n == nil {
		n = &tableCacheNode{
			fileNum:  fileNum,
			refCount: 1,
			result:   make(chan tableReaderOrError, 1),
		}
		c.nodes[fileNum] = n
		if len(c.nodes) > c.size {
			// Release the tail node.
			c.releaseNode(c.dummy.prev)
		}
		go n.load(c)
	} else {
		// Remove n from the doubly-linked list.
		n.next.prev = n.prev
		n.prev.next = n.next
	}
	// Insert n at the front of the doubly-linked list.
	n.next = c.dummy.next
	n.prev = &c.dummy
	n.next.prev = n
	n.prev.next = n
	// The caller is responsible for decrementing the refCount.
	n.refCount++
	return n
}
1206540
func (s *SymbolicLink) SetFileMode(v string) *SymbolicLink {
	s.FileMode = &v
	return s
}
464526
func (b *Blob) GetNodeID() string {
	if b == nil || b.NodeID == nil {
		return ""
	}
	return *b.NodeID
}
580282
func (m *Matcher) getFreeNode() *node {
	m.extent += 1

	if m.extent == 1 {
		m.root = &m.trie[0]
		m.root.root = true
	}

	return &m.trie[m.extent-1]
}
194504
func (c *Client) GetFile(fileID string) (*File, error) {
	req := url.Values{}
	req.Set("file_id", fileID)
	file := &File{}
	err := c.doRequest("getFile", req, file)
	return file, err
}
186512
func getPathFromFileNotFound(err error) (string, error) {
	if soap.IsSoapFault(err) {
		fault := soap.ToSoapFault(err)
		f, ok := fault.VimFault().(types.FileNotFound)
		if !ok {
			return "", fmt.Errorf("%v is not a FileNotFound error", err)
		}
		return f.File, nil
	}
	return "", fmt.Errorf("%v is not a soap fault", err)
}
693038
func (n *Mounter) GetFileType(pathname string) (mount.FileType, error) {
	var pathType mount.FileType
	outputBytes, err := n.ne.Exec("stat", []string{"-L", "--printf=%F", pathname}).CombinedOutput()
	if err != nil {
		if strings.Contains(string(outputBytes), "No such file") {
			err = fmt.Errorf("%s does not exist", pathname)
		} else {
			err = fmt.Errorf("stat %s error: %v", pathname, string(outputBytes))
		}
		return pathType, err
	}

	switch string(outputBytes) {
	case "socket":
		return mount.FileTypeSocket, nil
	case "character special file":
		return mount.FileTypeCharDev, nil
	case "block special file":
		return mount.FileTypeBlockDev, nil
	case "directory":
		return mount.FileTypeDirectory, nil
	case "regular file":
		return mount.FileTypeFile, nil
	}

	return pathType, fmt.Errorf("only recognise file, directory, socket, block device and character device")
}
1139274
func (c *Client) getFileDecoder(file string) decoder.API {
	for _, dc := range c.decoders {
		if dc.IsProcessable(file) {
			return dc
		}
	}
	return nil
}