files/file_info.go   A
last analyzed

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 11
eloc 41
dl 0
loc 71
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A files.*hdfsFileInfo.BlockSize 0 2 1
A files.*hdfsFileInfo.Name 0 2 1
A files.*hdfsFileInfo.Replication 0 2 1
A files.*hdfsFileInfo.OwnerGroup 0 2 1
A files.*hdfsFileInfo.getSys 0 2 1
A files.*hdfsFileInfo.Size 0 2 1
A files.*hdfsFileInfo.Mode 0 2 1
A files.*hdfsFileInfo.Owner 0 2 1
A files.*hdfsFileInfo.AccessTime 0 2 1
A files.*hdfsFileInfo.IsDir 0 2 1
A files.*hdfsFileInfo.ModTime 0 2 1
1
package files
2
3
import (
4
	"io/fs"
5
	"os"
6
	"time"
7
8
	"github.com/colinmarc/hdfs/protocol/hadoop_hdfs"
9
)
10
11
// HdfsFileInfo wrapper around os.FileInfo with some additional functions
12
// related to HDFS files.
13
type HdfsFileInfo interface {
14
	IsDir() bool
15
	ModTime() time.Time
16
	AccessTime() time.Time
17
	Mode() fs.FileMode
18
	Name() string
19
	Size() int64
20
	Owner() string
21
	OwnerGroup() string
22
	Replication() uint32
23
	BlockSize() uint64
24
}
25
26
type hdfsFileInfo struct {
27
	fileInfo os.FileInfo
28
}
29
30
func (h *hdfsFileInfo) IsDir() bool {
31
	return h.fileInfo.IsDir()
32
}
33
34
func (h *hdfsFileInfo) ModTime() time.Time {
35
	return h.fileInfo.ModTime()
36
}
37
38
func (h *hdfsFileInfo) AccessTime() time.Time {
39
	return time.Unix(int64(h.getSys().GetAccessTime())/1000, 0)
40
}
41
42
func (h *hdfsFileInfo) Mode() fs.FileMode {
43
	return h.fileInfo.Mode()
44
}
45
46
func (h *hdfsFileInfo) Name() string {
47
	return h.fileInfo.Name()
48
}
49
50
func (h *hdfsFileInfo) Size() int64 {
51
	return h.fileInfo.Size()
52
}
53
54
func (h *hdfsFileInfo) Owner() string {
55
	return h.getSys().GetOwner()
56
}
57
58
func (h *hdfsFileInfo) OwnerGroup() string {
59
	return h.getSys().GetGroup()
60
}
61
62
func (h *hdfsFileInfo) Replication() uint32 {
63
	return h.getSys().GetBlockReplication()
64
}
65
66
func (h *hdfsFileInfo) BlockSize() uint64 {
67
	return h.getSys().GetBlocksize()
68
}
69
70
func (h *hdfsFileInfo) getSys() *hadoop_hdfs.HdfsFileStatusProto {
71
	return h.fileInfo.Sys().(*hadoop_hdfs.HdfsFileStatusProto)
72
}
73