// TraceDirectory returns the path to the trace directory for a recording.
354384
func (c *RPCClient) TraceDirectory() (string, error) {
	var out RecordedOut
	err := c.call("Recorded", RecordedIn{}, &out)
	return out.TraceDirectory, err
}
1072397
func RunDirPath(dirPath string, args ...string) error {
	return RunIODirPath(IO{}, dirPath, args...)
}
436252
func writeDirectory(directory string, tarWriter *tar.Writer, subPath string) error {
	files, err := ioutil.ReadDir(directory)
	if err != nil {
		return err
	}

	for _, file := range files {
		currentPath := filepath.Join(directory, file.Name())
		if file.IsDir() {
			err := writeDirectory(currentPath, tarWriter, subPath)
			if err != nil {
				return err
			}
		} else {
			err = writeTarGz(currentPath, tarWriter, file, subPath)
			if err != nil {
				return err
			}
		}
	}

	return nil
}
1368807
func CreateDirectory(prefix string) (*Directory, error) {
	name, err := ioutil.TempDir("", prefix+"-")
	if err != nil {
		return nil, err
	}

	return &Directory{
		Name: name,
	}, nil
}
1027309
func (r *Router) TraceFunc(pattern string, fn http.HandlerFunc) Route {
	return r.Trace(pattern, http.HandlerFunc(fn))
}
608390
func CopyDirectory(src, dest string) error {
	return filepath.Walk(src, func(path string, info os.FileInfo, err error) error {
		subPath := path + "/" + info.Name()
		if info.IsDir() {
			return MkdirAll(subPath, filesystem.DefaultUnixDirMode)
		}
		return CopyFile(src+subPath, dest+subPath)
	})
}
648388
func (l *SysLogger) Tracef(format string, v ...interface{}) {
	if l.trace {
		l.writer.Info(4, formatMsg("TRACE", format, v...))
	}
}
290442
func (e *Error) trace(fields ...string) *Error {
	if e == nil {
		return nil
	}
	pc, file, line, _ := runtime.Caller(2)
	function := runtime.FuncForPC(pc).Name()
	_, function = filepath.Split(function)
	file = strings.TrimPrefix(file, rootPath+string(os.PathSeparator)) // trims project's root path.
	tp := TracePoint{}
	if len(fields) > 0 {
		tp = TracePoint{Line: line, Filename: file, Function: function, Env: map[string][]string{"Tags": fields}}
	} else {
		tp = TracePoint{Line: line, Filename: file, Function: function}
	}
	e.CallTrace = append(e.CallTrace, tp)
	return e
}
1075814
func (dl *ConsoleLogger) Trace(message interface{}, params ...interface{}) {
	dl.logger.Tracef(fmt.Sprintf("%s %s", caller(), fmt.Sprint(message)), params...)
}
1137503
func TraceHandler() echo.HandlerFunc {
	return func(ctx echo.Context) error {
		Trace(ctx)
		return nil
	}
}
385619
func (t *Trace) String() string {
	dir, file := filepath.Split(t.Path)
	dirs := strings.Split(filepath.ToSlash(filepath.Clean(dir)), "/")
	if len(dirs) != 0 {
		file = filepath.Join(dirs[len(dirs)-1], file)
	}
	return fmt.Sprintf("%v:%v", file, t.Line)
}
729538
func createDirectory(dir string, perms os.FileMode) error {
	// This prevents someone passing /path/to/dir and 'dir' not being created
	// If two '//' exist, MkdirAll deals it with correctly
	dir = dir + "/"
	return os.MkdirAll(dir, perms)
}
604075
func TraceHandler() gin.HandlerFunc {
	return func(ctx *gin.Context) {
		pprof.Trace(ctx.Writer, ctx.Request)
	}
}
509146
func (h *fs) RemoveDirectory(dir string) error {
	glog.V(2).Infof("Removing directory '%s'", dir)

	// HACK: If deleting a directory in windows, call out to the system to do the deletion
	// TODO: Remove this workaround when we switch to go 1.7 -- os.RemoveAll should
	// be fixed for Windows in that release.  https://github.com/golang/go/issues/9606
	if runtime.GOOS == "windows" {
		command := exec.Command("cmd.exe", "/c", fmt.Sprintf("rd /s /q %s", dir))
		output, err := command.Output()
		if err != nil {
			glog.Errorf("Error removing directory %q: %v %s", dir, err, string(output))
			return err
		}
		return nil
	}

	err := os.RemoveAll(dir)
	if err != nil {
		glog.Errorf("Error removing directory '%s': %v", dir, err)
	}
	return err
}
1317784
func (nm DatastoreNamespaceManager) DeleteDirectory(ctx context.Context, dc *Datacenter, datastorePath string) error {

	req := &types.DeleteDirectory{
		This:          nm.Reference(),
		DatastorePath: datastorePath,
	}

	if dc != nil {
		ref := dc.Reference()
		req.Datacenter = &ref
	}

	if _, err := methods.DeleteDirectory(ctx, nm.c, req); err != nil {
		return err
	}

	return nil
}
1317043
func (c *Client) TraceOn(outputStream io.Writer) {
	// if outputStream is nil then default to os.Stdout.
	if outputStream == nil {
		outputStream = os.Stdout
	}
	// Sets a new output stream.
	c.traceOutput = outputStream

	// Enable tracing.
	c.isTraceEnabled = true
}
702359
func Replay(tracedir string, quiet bool, debugInfoDirs []string) (*Process, error) {
	if err := checkRRAvailabe(); err != nil {
		return nil, err
	}

	rrcmd := exec.Command("rr", "replay", "--dbgport=0", tracedir)
	rrcmd.Stdout = os.Stdout
	stderr, err := rrcmd.StderrPipe()
	if err != nil {
		return nil, err
	}
	rrcmd.SysProcAttr = sysProcAttr(false)

	initch := make(chan rrInit)
	go rrStderrParser(stderr, initch, quiet)

	err = rrcmd.Start()
	if err != nil {
		return nil, err
	}

	init := <-initch
	if init.err != nil {
		rrcmd.Process.Kill()
		return nil, init.err
	}

	p := New(rrcmd.Process)
	p.tracedir = tracedir
	err = p.Dial(init.port, init.exe, 0, debugInfoDirs)
	if err != nil {
		rrcmd.Process.Kill()
		return nil, err
	}

	return p, nil
}