// CanDeleteFile - return just nil
// TODO check for permissions here.
336856
func (f *File) CanDeleteFile(ctx context.Context, fi *dokan.FileInfo) error {
	f.folder.fs.logEnterf(ctx, "File CanDeleteFile for %q", f.name)
	return nil
}
1044239
func (api *API) DeleteUserAccessRule(accessRuleID string) (*AccessRuleResponse, error) {
	return api.deleteAccessRule("/user", accessRuleID)
}
572282
func WriteFile(filename string, data []byte, perm os.FileMode) error {
	// find the dirname of the filename

	d := filepath.Dir(filename)
	if err := os.MkdirAll(d, 0755); err != nil {
		return err
	}

	tempfile, err := ioutil.TempFile(d, filepath.Base(filename))
	if err != nil {
		return err
	}
	name := tempfile.Name()
	defer os.Remove(name)

	if err := tempfile.Close(); err != nil {
		return err
	}

	if err := ioutil.WriteFile(name, data, perm); err != nil {
		return err
	}

	if err := os.Chmod(name, perm); err != nil {
		return err
	}
	return os.Rename(name, filename)
}
291176
func lockedOpenFile(path string, flag int, perm os.FileMode, lockType uint32) (*LockedFile, error) {
	f, err := Open(path, flag, perm)
	if err != nil {
		return nil, err
	}

	if err = lockFile(syscall.Handle(f.Fd()), lockType); err != nil {
		f.Close()
		return nil, err
	}

	st, err := os.Stat(path)
	if err != nil {
		f.Close()
		return nil, err
	}

	if st.IsDir() {
		f.Close()
		return nil, &os.PathError{
			Op:   "open",
			Path: path,
			Err:  syscall.EISDIR,
		}
	}

	return &LockedFile{File: f}, nil
}
507657
func Delete() error {
	filename := locateSettingsFile()

	if _, err := os.Stat(filename); err != nil {
		if os.IsNotExist(err) {
			return nil
		}

		return err
	}

	if err := os.Remove(filename); err != nil {
		return err
	}

	return nil
}
632320
func (client *Client) DeleteScalingRule(args *DeleteScalingRuleArgs) (resp *DeleteScalingRuleResponse, err error) {
	response := DeleteScalingRuleResponse{}
	err = client.InvokeByFlattenMethod("DeleteScalingRule", args, &response)

	if err != nil {
		return nil, err
	}
	return &response, nil
}
1060709
func canAccessFile(path string) bool {
	if fi, err := os.Stat(path); err == nil {
		return fi.Mode().Perm()&0400 != 0
	}
	return false
}
245020
func (a Afero) WriteFile(filename string, data []byte, perm os.FileMode) error {
	return WriteFile(a.Fs, filename, data, perm)
}
1067856
func RemoveFile(pth string) error {
	if exist, err := pathutil.IsPathExists(pth); err != nil {
		return err
	} else if exist {
		if err := os.Remove(pth); err != nil {
			return err
		}
	}
	return nil
}
508228
func (self *RotatingFileHandler) RotateFile(sourceFile, destFile string) error {
	if FileExists(sourceFile) {
		if FileExists(destFile) {
			if err := os.Remove(destFile); err != nil {
				return err
			}
		}
		if err := os.Rename(sourceFile, destFile); err != nil {
			return err
		}
	}
	return nil
}
1096508
func (s *Server) deletePortsFile(hintDir string) {
	portsFile := s.portFile(hintDir)
	if portsFile != "" {
		if err := os.Remove(portsFile); err != nil {
			s.Errorf("Error cleaning up ports file %s: %v", portsFile, err)
		}
	}
}
158428
func (f *fileStorage) Delete(key string) error {
	return os.Remove(f.filePathToFile(key))
}
649459
func (fm *filesManager) closeLockedFile(file *file) error {
	if !atomic.CompareAndSwapInt32(&file.state, fileInUse, fileClosing) {
		panic(fmt.Errorf("file %q is requested to be closed but was not locked by caller", file.name))
	}
	fm.Lock()
	err := fm.doClose(file)
	fm.Unlock()
	return err
}
1179076
func (c *Client) DeleteFile(id, name string) error {
	res, err := c.doRequest("b2_delete_file_version", map[string]interface{}{
		"fileId": id, "fileName": name,
	})
	if err != nil {
		return err
	}
	drainAndClose(res.Body)
	return nil
}
468507
func deleteFile(filename string) error {
	if fileExists(filename) {
		return os.Remove(filename)
	}
	return nil
}
518104
func (ac *accountCache) deleteByFile(path string) {
	ac.mu.Lock()
	defer ac.mu.Unlock()
	i := sort.Search(len(ac.all), func(i int) bool { return ac.all[i].URL.Path >= path })

	if i < len(ac.all) && ac.all[i].URL.Path == path {
		removed := ac.all[i]
		ac.all = append(ac.all[:i], ac.all[i+1:]...)
		if ba := removeAccount(ac.byAddr[removed.Address], removed); len(ba) == 0 {
			delete(ac.byAddr, removed.Address)
		} else {
			ac.byAddr[removed.Address] = ba
		}
	}
}
602712
func CloseFile(f *os.File) {
	if err := f.Close(); err != nil {
		glog.Warningf("unable to close file %s: %v", f.Name(), err)
	}
}