// Copyright (C) 2019 Marius Schellenberger

package authdav

import (
	"golang.org/x/net/webdav"
	"io"
	"os"
)

// File is a wrapper for webdav.File providing write only functionality
type File struct {
	f webdav.File
}

func (f *File) Close() error {
	return f.f.Close()
}

func (f *File) Read(p []byte) (int, error) {
	return 0, io.EOF
}

func (f *File) Seek(offset int64, whence int) (int64, error) {
	return 0, nil
}

func (f *File) Readdir(count int) (fi []os.FileInfo, err error) {
	ffi, err := f.f.Readdir(count)
	for _, f := range ffi {
		fi = append(fi, &FileInfo{f})
	}
	return
}

func (f *File) Stat() (os.FileInfo, error) {
	fi, err := f.f.Stat()
	if err != nil {
		return nil, err
	}
	return &FileInfo{fi}, nil
}

func (f *File) Write(p []byte) (int, error) {
	return f.f.Write(p)
}
