本文整理汇总了Golang中github.com/spf13/afero.File.Name方法的典型用法代码示例。如果您正苦于以下问题:Golang File.Name方法的具体用法?Golang File.Name怎么用?Golang File.Name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/spf13/afero.File
的用法示例。
在下文中一共展示了File.Name方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: checkSize
func checkSize(t *testing.T, f afero.File, size int64) {
dir, err := f.Stat()
if err != nil {
t.Fatalf("Stat %q (looking for size %d): %s", f.Name(), size, err)
}
if dir.Size() != size {
t.Errorf("Stat %q: size %d want %d", f.Name(), dir.Size(), size)
}
}
示例2: registerDirs
func (m *MemS3Fs) registerDirs(f afero.File) {
var x = f.Name()
for x != "/" {
f := m.registerWithParent(f)
if f == nil {
break
}
x = f.Name()
}
}
示例3: readForever
func (t *Tailer) readForever(f afero.File) {
var err error
partial := ""
for {
partial, err = t.read(f, partial)
// We want to exit at EOF, because the FD has been closed.
if err != nil {
glog.Infof("%s: %s", err, f.Name())
return
}
}
}
示例4: findParent
func (m *MemS3Fs) findParent(f afero.File) afero.File {
dirs, _ := path.Split(f.Name())
if len(dirs) > 1 {
_, parent := path.Split(path.Clean(dirs))
if len(parent) > 0 {
pfile, err := m.Open(parent)
if err != nil {
return pfile
}
}
}
return nil
}
示例5: registerWithParent
func (m *MemS3Fs) registerWithParent(f afero.File) afero.File {
if f == nil {
return nil
}
parent := m.findParent(f)
if parent != nil {
pmem := parent.(*InMemoryFile)
pmem.memDir.Add(f)
} else {
pdir := filepath.Dir(path.Clean(f.Name()))
m.Mkdir(pdir, 0777)
}
return parent
}
示例6: startNewFile
func (t *Tailer) startNewFile(f afero.File, seekStart bool) error {
fi, err := f.Stat()
if err != nil {
// Stat failed, log error and return.
logErrors.Add(f.Name(), 1)
return fmt.Errorf("Failed to stat %q: %s", f.Name(), err)
}
switch m := fi.Mode(); {
case m&os.ModeType == 0:
if seekStart {
f.Seek(0, os.SEEK_SET)
} else {
f.Seek(0, os.SEEK_END)
}
err = t.w.Add(f.Name())
if err != nil {
return fmt.Errorf("Adding a change watch failed on %q: %s", f.Name(), err)
}
// In case the new log has been written to already, attempt to read the
// first lines.
t.partials[f.Name()], err = t.read(f, "")
if err != nil {
if err == io.EOF {
// Don't worry about EOF on first read, that's expected.
break
}
return err
}
case m&os.ModeType == os.ModeNamedPipe:
go t.readForever(f)
default:
return fmt.Errorf("Can't open files with mode %v: %s", m&os.ModeType, f.Name())
}
t.filesLock.Lock()
t.files[f.Name()] = f
t.filesLock.Unlock()
glog.Infof("Tailing %s", f.Name())
return nil
}
示例7: Remove
func (m MemDirMap) Remove(f afero.File) { delete(m, f.Name()) }
示例8: Add
func (m MemDirMap) Add(f afero.File) { m[f.Name()] = f }