package integration import ( "time" "os" "path" "caj-larsson/bog/domain" ) type FileSystemBogFileData struct { path string file *os.File } func (f FileSystemBogFileData) Read(p []byte) (int, error) { return f.file.Read(p) } func (f FileSystemBogFileData) Write(p []byte) (int, error) { return f.file.Write(p) } func (f FileSystemBogFileData) Close() error { return f.file.Close() } func (f FileSystemBogFileData) Seek(offset int64, whence int) (int64, error) { return f.file.Seek(offset, whence) } func (f FileSystemBogFileData) Path() string { return f.path } func (f FileSystemBogFileData) Size() int64 { return 0 } func (f FileSystemBogFileData) Modified() time.Time{ return time.Now() } type FileSystemBogRepository struct { Root string } func (f FileSystemBogRepository) OpenOrCreate(open_path string, user_agent string) (domain.BogFileData, error) { //file_name := path.Base(open_path) abs_path := path.Join(f.Root, open_path) dir := path.Dir(abs_path) os.MkdirAll(dir, 0750) file, err := os.OpenFile(abs_path, os.O_RDWR|os.O_CREATE, 0644) if err != nil { panic(err) } bfd := FileSystemBogFileData {open_path, file} return bfd, nil } func (f FileSystemBogRepository) Delete(file *domain.BogFileData) { }