本文整理汇总了Golang中os.FileInfo.IsRegular方法的典型用法代码示例。如果您正苦于以下问题:Golang FileInfo.IsRegular方法的具体用法?Golang FileInfo.IsRegular怎么用?Golang FileInfo.IsRegular使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类os.FileInfo
的用法示例。
在下文中一共展示了FileInfo.IsRegular方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: fileExists
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()
}
示例2: getEntryTypeString
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 ""
}
示例3: visitFile
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()
}
示例4: MakeDotGraph
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()
}
示例5: isGoFile
func isGoFile(fi *os.FileInfo) bool {
return fi.IsRegular() && // exclude directories
!strings.HasPrefix(fi.Name, ".") && // ignore .files
filepath.Ext(fi.Name) == ".go"
}
示例6: isGoFile
func isGoFile(f *os.FileInfo) bool {
// ignore non-Go files
return f.IsRegular() && !strings.HasPrefix(f.Name, ".") && strings.HasSuffix(f.Name, ".go")
}
示例7: isGoFile
func isGoFile(f *os.FileInfo) bool {
return f.IsRegular() &&
!strings.HasPrefix(f.Name, ".") && // ignore .files
filepath.Ext(f.Name) == ".go"
}
示例8: isHeader
func isHeader(f *os.FileInfo) bool {
return f.IsRegular() && !strings.HasPrefix(f.Name, ".") &&
strings.HasSuffix(f.Name, ".h")
}
示例9: isGoFile
func isGoFile(dir *os.FileInfo) bool {
return dir.IsRegular() &&
!strings.HasPrefix(dir.Name, ".") && // ignore .files
path.Ext(dir.Name) == ".go"
}