code: func (fm *filesManager) closeFileIfOpened(file *file) error {
  	if !atomic.CompareAndSwapInt32(&file.state, fileOpened, fileClosing) {
  		return nil
  	}
  	fm.Lock()
  	err := fm.doClose(file)
  	fm.Unlock()
  	return err
  }
docs: // closeFileIfOpened closes the handle of the given file, but only if the
  // file is opened and not currently locked. Does not return any error or panic
  // if file is in any other state.
  // If the file's beforeClose callback is not nil, this callback is invoked
  // before the file handle is closed.