Ejemplo n.º 1
0
func (serv *workspace) dircontent(fs filesystem.WorkspaceFS, fl filesystem.WorkspaceFile, path string, request *restful.Request, response *restful.Response) {
	var result dir
	flz, err := fl.Readdir(-1)
	if err != nil {
		sendError(response, http.StatusBadRequest, fmt.Errorf("Cannot read contents of '%s': %s", path, err))
	} else {
		for _, fli := range flz {
			abs, _, _, e := filesystem.AbsolutePath(fs, path)
			if e != nil {
				sendError(response, http.StatusBadRequest, fmt.Errorf("Cannot read contents of '%s': %s", path, err))
			}
			isd, e := isDir(abs, fli)
			if e != nil {
				sendError(response, http.StatusBadRequest, fmt.Errorf("Cannot read dir status of '%s/%#v': %s", abs, fli, err))
			}
			result.Entries = append(result.Entries, dirEntry{fs.Name(), fli.Name(), isd})
		}
		response.WriteEntity(&result)
	}
}
Ejemplo n.º 2
0
func appendTokenPosition(fs filesystem.WorkspaceFS, ar []TokenPosition, pos token.Position, name, target string, tt TokenType) []TokenPosition {
	pt := pos.Filename
	var fsname string
	if fs != nil {
		fsname = fs.Name()
		if pat, err := filepath.Rel(fs.Base(), pos.Filename); err == nil {
			pt = pat
		} else {
			buildLogger.Errorf("Path is not relative to Filesystem: %s", err)
		}
	}
	tp := TokenPosition{Type: tt,
		Source:     "/" + pt,
		Name:       name,
		Target:     target,
		Line:       pos.Line,
		Offset:     pos.Offset,
		Column:     pos.Column,
		Filesystem: fsname,
		Filename:   filepath.Base(pos.Filename),
		Package:    "/" + filepath.Dir(pt)}
	return append(ar, tp)
}