// checkForTruncate stats the filename to see if the file has shrunk and therefore been truncated
// This isn't expected to handle IO errors, simply return True if the file has been truncated. (IO Errors may interfere with this happening)
426954
func (t *File) checkForTruncate() bool {
	s, err := os.Stat(t.filename)
	if os.IsNotExist(err) {
		return false
	}
	if err != nil {
		return false
	}

	if s.Size() < t.fileSize {
		// File size shrunk, that is the sign for truncation
		t.fileSize = s.Size()
		return true
	}

	t.fileSize = s.Size()
	return false
}
159523
func (e *FileEvent) IsModify() bool {
	return ((e.mask&sys_NOTE_WRITE) == sys_NOTE_WRITE || (e.mask&sys_NOTE_ATTRIB) == sys_NOTE_ATTRIB)
}
477934
func IsCanceled(err error) bool {
	return isCausedBy(err, func(e error) bool { return e == context.Canceled })
}
993099
func (b *BlockServerMemory) IsUnflushed(ctx context.Context, tlfID tlf.ID,
	_ kbfsblock.ID) (bool, error) {
	b.lock.RLock()
	defer b.lock.RUnlock()

	if b.m == nil {
		return false, errBlockServerMemoryShutdown
	}

	return false, nil
}
865703
func (bz *Bz2) CheckExt(filename string) error {
	if filepath.Ext(filename) != ".bz2" {
		return fmt.Errorf("filename must have a .bz2 extension")
	}
	return nil
}
84829
func DoesFileExist(fileName string) bool {
	_, err := os.Stat(fileName)
	if os.IsNotExist(err) {
		return false
	}
	return true
}
232087
func (sa *stagedArchival) checkComplete(c context.Context) error {
	if sa.terminalIndex < 0 {
		log.Warningf(c, "Cannot archive complete stream with no terminal index.")
		return statusErr(errors.New("completeness required, but stream has no terminal index"))
	}

	sreq := storage.GetRequest{
		Project:  sa.project,
		Path:     sa.path,
		KeysOnly: true,
	}

	nextIndex := types.MessageIndex(0)
	var ierr error
	err := sa.Storage.Get(c, sreq, func(e *storage.Entry) bool {
		idx, err := e.GetStreamIndex()
		if err != nil {
			ierr = errors.Annotate(err, "could not get stream index").Err()
			return false
		}

		switch {
		case idx != nextIndex:
			ierr = fmt.Errorf("missing log entry index %d (next %d)", nextIndex, idx)
			return false

		case idx == sa.terminalIndex:
			// We have hit our terminal index, so all of the log data is here!
			return false

		default:
			nextIndex++
			return true
		}
	})
	if ierr != nil {
		return ierr
	}
	if err != nil {
		return err
	}
	return nil
}
970797
func (f *File) Check() {
	// TODO
	typs := make(map[ast.Expr]types.TypeAndValue)
	defs := make(map[*ast.Ident]types.Object)
	uses := make(map[*ast.Ident]types.Object)
	config := types.Config{FakeImportC: true}
	config.Importer = importer.Default()
	info := &types.Info{Types: typs, Defs: defs, Uses: uses}
	astFiles := []*ast.File{f.ast}
	typesPkg, err := config.Check(fileDir(f), f.fs, astFiles, info)
	if err != nil {
		log.Fatalf("checking package: %s", err)
	}
	f.Info = info
	f.Pkg = typesPkg
}
383713
func HasExtension(filename string, extensions map[string]bool) bool {
	var ext string
	if e := filepath.Ext(filename); strings.HasPrefix(e, ".") {
		ext = e[1:]
	} else {
		return false
	}

	// Case-insensitive lookup.
	// Optimistically assume a short ASCII extension and be
	// allocation-free in that case.
	var buf [10]byte
	lower := buf[:0]
	const utf8RuneSelf = 0x80 // from utf8 package, but not importing it.
	for i := 0; i < len(ext); i++ {
		c := ext[i]
		if c >= utf8RuneSelf {
			// Slow path.
			return extensions[strings.ToLower(ext)]
		}
		if 'A' <= c && c <= 'Z' {
			lower = append(lower, c+('a'-'A'))
		} else {
			lower = append(lower, c)
		}
	}
	// The conversion from []byte to string doesn't allocate in
	// a map lookup.
	return extensions[string(lower)]
}
16401
func FileExistsOfSize(path string, sz int64) bool {
	fi, err := os.Stat(path)

	if err != nil {
		return false
	}

	return !fi.IsDir() && fi.Size() == sz
}
332080
func CheckFile(name string) (bool, error) {
	f, err := os.Open(name)
	if err != nil {
		if os.IsNotExist(err) {
			f, err = os.Create(name)
			if err != nil {
				return false, err
			}
			return false, f.Chmod(0600)
		}
		return false, err
	}
	defer f.Close()

	fi, err := f.Stat()
	if err != nil {
		return false, err
	}

	return fi.Size() > 0, nil
}
858281
func (checker *diffChecker) Check(params []interface{}, names []string) (result bool, error string) {
	if len(params) != 2 || len(names) != 2 {
		return false, "params and names must be of length 2"
	}

	if reflect.DeepEqual(params[0], params[1]) {
		return true, ""
	}

	return false, comparator.CompareWithNames(params[0], params[1], names[0], names[1])
}
756437
func (*Zip) CheckExt(filename string) error {
	if !strings.HasSuffix(filename, ".zip") {
		return fmt.Errorf("filename must have a .zip extension")
	}
	return nil
}
966528
func (pc PrefixCodes) checkLengths() bool {
	sum := 1 << valueBits
	for _, c := range pc {
		sum -= (1 << valueBits) >> uint(c.Len)
	}
	return sum == 0 || len(pc) == 0
}
633590
func (e *FileEvent) IsRename() bool {
	return ((e.mask&sys_FS_MOVE) == sys_FS_MOVE || (e.mask&sys_FS_MOVE_SELF) == sys_FS_MOVE_SELF || (e.mask&sys_FS_MOVED_FROM) == sys_FS_MOVED_FROM || (e.mask&sys_FS_MOVED_TO) == sys_FS_MOVED_TO)
}
1343263
func (file *File) Close() (err error) {
	defer func() {
		if err != nil {
			os.Remove(file.tmpfile.Name())
			file.aborted = true
		}
	}()

	if file.closed {
		err = errors.New("close on closed file")
		return
	}
	if file.aborted {
		err = errors.New("close on aborted file")
		return
	}

	if err = file.tmpfile.Close(); err != nil {
		return
	}

	err = os.Rename(file.tmpfile.Name(), file.name)

	file.closed = true
	return
}
1062921
func (x *Xz) CheckExt(filename string) error {
	if filepath.Ext(filename) != ".xz" {
		return fmt.Errorf("filename must have a .xz extension")
	}
	return nil
}