You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
654 B
Go
50 lines
654 B
Go
package swampfile
|
|
|
|
import (
|
|
"io"
|
|
"path"
|
|
"path/filepath"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
type SwampOutFile interface {
|
|
Path() string
|
|
Size() int64
|
|
Modified() time.Time
|
|
io.Reader
|
|
io.Seeker
|
|
io.Closer
|
|
}
|
|
|
|
type SwampInFile interface {
|
|
Path() string
|
|
Size() int64
|
|
Modified() time.Time
|
|
io.Writer
|
|
io.Seeker
|
|
io.Closer
|
|
}
|
|
|
|
type FileReference struct {
|
|
Path string
|
|
UserAgent string
|
|
}
|
|
|
|
type DeletedSwampFile struct {
|
|
Path string
|
|
Size int64
|
|
}
|
|
|
|
func (fr *FileReference) Clean(strict bool) error {
|
|
c := filepath.FromSlash(path.Clean("/" + strings.Trim(fr.Path, "/")))
|
|
|
|
if c != fr.Path && strict {
|
|
return ErrUnacceptablePath
|
|
}
|
|
|
|
fr.Path = c
|
|
|
|
return nil
|
|
}
|