func (fs *Filesystem) WriteFile(filename string, data []byte, perm os.FileMode) error {
	f, err := fs.Open(filename)
	if err != nil {
		fs.Lock()
		defer fs.Unlock()
		fParent, errParent := fs.root.lookupFile(filename, path.Dir(filename))
		if errParent != nil {
			return errParent
		}
		f = NewFile(fs, fParent, path.Base(filename), perm, time.Now(), false)
	}
	ff := f.(*File)
	ff.Lock()
	defer ff.Unlock()
	ff.content = make([]byte, len(data))
	copy(ff.content, data)
	return nil
}
WriteFile reads a file and returns the contents
package fake
import (
	"errors"
	"os"
	"path"
	"strings"
	"sync"
	"time"
	"github.com/lemonldap-ng-controller/lemonldap-ng-controller/internal/filesystem"
)
type Filesystem struct {
	sync.RWMutex  
	root *File
}
func NewFilesystem() *Filesystem {
	fs := &Filesystem{}
	fs.root = NewFile(fs, nil, "/", 0755, time.Now(), true)
	fs.Mkdir("/var", 0755)
	fs.Mkdir("/var/lib", 0755)
	fs.Mkdir("/var/lib/lemonldap-ng", 0755)
	fs.Mkdir("/var/lib/lemonldap-ng/conf", 0755)
	content := []byte(`{
		"applicationList": {},
		"cfgNum": 1,
		"exportedHeaders": {},
		"locationRules": {},
		"reloadUrls": {
			"reload.example.com" : "http://reload.example.com/reload"
		}
	}`)
	fs.WriteFile("/var/lib/lemonldap-ng/conf/lmConf-1.js", content, 0644)
	return fs
}
func (fs *Filesystem) Mkdir(name string, perm os.FileMode) error {
	fs.Lock()
	defer fs.Unlock()
	_, err := fs.root.lookupFile(name, name)
	if err == nil {
		return &os.PathError{
			Op:   "mkdir",
			Path: name,
			Err:  errors.New("File exists"),  
		}
	}
	dirName := path.Dir(name)
	fParent, errParent := fs.root.lookupFile(dirName, dirName)
	if errParent != nil {
		return &os.PathError{
			Op:   "mkdir",
			Path: name,
			Err:  errParent.(*os.PathError).Err,
		}
	}
	NewFile(fs, fParent, path.Base(name), perm, time.Now(), true)
	return nil
}
func (fs *Filesystem) Open(name string) (filesystem.File, error) {
	fs.RLock()
	defer fs.RUnlock()
	return fs.root.lookupFile(name, name)
}
func (fs *Filesystem) Stat(name string) (os.FileInfo, error) {
	f, err := fs.Open(name)
	if err != nil {
		return nil, err
	}
	ff := f.(*File)
	return ff, nil
}
func (fs *Filesystem) ReadFile(filename string) ([]byte, error) {
	f, err := fs.Open(filename)
	if err != nil {
		return []byte(""), err
	}
	ff := f.(*File)
	ff.RLock()
	defer ff.RUnlock()
	c := make([]byte, len(ff.content))
	copy(c, ff.content)
	return c, nil
}