Esempio n. 1
1
func fileExists(path string) bool {
	var f *os.FileInfo
	var err os.Error

	if f, err = os.Stat(path); err != nil {
		return false
	}

	return f.IsRegular()
}
Esempio n. 2
1
func getEntryTypeString(e *os.FileInfo) string {
	if e.IsDirectory() {
		return "/"
	} else if e.IsBlock() {
		return "<>"
	} else if e.IsFifo() {
		return ">>"
	} else if e.IsSymlink() {
		return "@"
	} else if e.IsSocket() {
		return "&"
	} else if e.IsRegular() && (e.Mode&0001 == 0001) {
		return "*"
	}
	return ""
}
Esempio n. 3
0
func (x *Indexer) visitFile(dirname string, f *os.FileInfo, fulltextIndex bool) {
	if !f.IsRegular() {
		return
	}

	filename := filepath.Join(dirname, f.Name)
	goFile := false

	switch {
	case isGoFile(f):
		if !includeTestFiles && (!isPkgFile(f) || strings.HasPrefix(filename, "test/")) {
			return
		}
		if !includeMainPackages && pkgName(filename) == "main" {
			return
		}
		goFile = true

	case !fulltextIndex || !isWhitelisted(f.Name):
		return
	}

	file, fast := x.addFile(filename, goFile)
	if file == nil {
		return // addFile failed
	}

	if fast != nil {
		// we've got a Go file to index
		x.current = file
		dir, _ := filepath.Split(filename)
		pak := Pak{dir, fast.Name.Name}
		x.file = &File{filename, pak}
		ast.Walk(x, fast)
	}

	// update statistics
	x.stats.Bytes += file.Size()
	x.stats.Files++
	x.stats.Lines += file.LineCount()
}
Esempio n. 4
0
func (d Dag) MakeDotGraph(filename string) {

	var file *os.File
	var fileinfo *os.FileInfo
	var e os.Error
	var sb *stringbuffer.StringBuffer

	fileinfo, e = os.Stat(filename)

	if e == nil {
		if fileinfo.IsRegular() {
			e = os.Remove(fileinfo.Name)
			if e != nil {
				log.Fatalf("[ERROR] failed to remove: %s\n", filename)
			}
		}
	}

	sb = stringbuffer.NewSize(500)
	file, e = os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0644)

	if e != nil {
		log.Fatalf("[ERROR] %s\n", e)
	}

	sb.Add("digraph depgraph {\n\trankdir=LR;\n")

	for _, v := range d {
		v.DotGraph(sb)
	}

	sb.Add("}\n")

	file.WriteString(sb.String())

	file.Close()

}
Esempio n. 5
0
File: package.go Progetto: ssrl/go
func isGoFile(fi *os.FileInfo) bool {
	return fi.IsRegular() && // exclude directories
		!strings.HasPrefix(fi.Name, ".") && // ignore .files
		filepath.Ext(fi.Name) == ".go"
}
Esempio n. 6
0
func isGoFile(f *os.FileInfo) bool {
	// ignore non-Go files
	return f.IsRegular() && !strings.HasPrefix(f.Name, ".") && strings.HasSuffix(f.Name, ".go")
}
Esempio n. 7
0
func isGoFile(f *os.FileInfo) bool {
	return f.IsRegular() &&
		!strings.HasPrefix(f.Name, ".") && // ignore .files
		filepath.Ext(f.Name) == ".go"
}
Esempio n. 8
0
func isHeader(f *os.FileInfo) bool {
	return f.IsRegular() && !strings.HasPrefix(f.Name, ".") &&
		strings.HasSuffix(f.Name, ".h")
}
func isGoFile(dir *os.FileInfo) bool {
	return dir.IsRegular() &&
		!strings.HasPrefix(dir.Name, ".") && // ignore .files
		path.Ext(dir.Name) == ".go"
}