-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvfs.go
50 lines (44 loc) · 1.51 KB
/
vfs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) Jeevanandam M. (https://github.com/jeevatkm)
// aahframework.org/vfs source code and usage is governed by a MIT style
// license that can be found in the LICENSE file.
// Package vfs provides Virtual FileSystem (VFS) capability. Typically it reflects
// OS FileSystem behavior in-memory.
//
// aah vfs is Read-Only, even though vfs design nature could support Write
// operations. I have limited it.
//
// The methods should behave the same as those on an *os.File for Read-Only.
package vfs
import (
"net/http"
"os"
)
// FileSystem interface implements access to a collection of named files.
// The elements in a file path are separated by slash ('/', U+002F) characters,
// regardless of host operating system convention.
type FileSystem interface {
Open(name string) (File, error)
Lstat(name string) (os.FileInfo, error)
Stat(name string) (os.FileInfo, error)
ReadFile(filename string) ([]byte, error)
ReadDir(dirname string) ([]os.FileInfo, error)
Glob(pattern string) ([]string, error)
IsExists(name string) bool
}
// File interface returned by a vfs.FileSystem's Open method.
type File interface {
http.File
Readdirnames(n int) ([]string, error)
}
// RawBytes interface is to retrieve underlying file's raw bytes.
//
// Note: It could be gzip or non-gzip bytes. Use interface `Gziper`
// to identify byte classification.
type RawBytes interface {
RawBytes() []byte
}
// Gziper interface is to identify whether the file's raw bytes is gzipped or not.
type Gziper interface {
RawBytes
IsGzip() bool
}