code: func (fm *filesManager) createFile(name string, flags int, bfc beforeFileClose) (*file, error) {
  	fm.Lock()
  	if fm.isClosed {
  		fm.Unlock()
  		return nil, fmt.Errorf("unable to create file %q, store is being closed", name)
  	}
  	if fm.limit > 0 && fm.openedFDs >= fm.limit {
  		fm.closeUnusedFiles(0)
  	}
  	fileName := filepath.Join(fm.rootDir, name)
  	handle, err := openFileWithFlags(fileName, flags)
  	if err != nil {
  		fm.Unlock()
  		return nil, err
  	}
  	fm.nextID++
  	newFile := &file{
  		state:       fileInUse,
  		id:          fm.nextID,
  		handle:      handle,
  		name:        fileName,
  		flags:       flags,
  		beforeClose: bfc,
  	}
  	fm.files[newFile.id] = newFile
  	fm.openedFDs++
  	fm.Unlock()
  	return newFile, nil
  }
docs: // createFile creates a file, open it, adds it to the list of files and returns
  // an instance of `*file` with the state sets to `fileInUse`.
  // This call will possibly cause opened but unused files to be closed if the
  // number of open file requests is above the set limit.