fileinfo.go 951 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
  2. //
  3. // This Source Code Form is subject to the terms of the MIT License.
  4. // If a copy of the MIT was not distributed with this file,
  5. // You can obtain one at https://github.com/gogf/gf.
  6. // Package fileinfo provides virtual os.FileInfo for given information.
  7. package fileinfo
  8. import (
  9. "os"
  10. "time"
  11. )
  12. type Info struct {
  13. name string
  14. size int64
  15. mode os.FileMode
  16. modTime time.Time
  17. }
  18. func New(name string, size int64, mode os.FileMode, modTime time.Time) *Info {
  19. return &Info{
  20. name: name,
  21. size: size,
  22. mode: mode,
  23. modTime: modTime,
  24. }
  25. }
  26. func (i *Info) Name() string {
  27. return i.name
  28. }
  29. func (i *Info) Size() int64 {
  30. return i.size
  31. }
  32. func (i *Info) IsDir() bool {
  33. return i.mode.IsDir()
  34. }
  35. func (i *Info) Mode() os.FileMode {
  36. return i.mode
  37. }
  38. func (i *Info) ModTime() time.Time {
  39. return i.modTime
  40. }
  41. func (i *Info) Sys() interface{} {
  42. return nil
  43. }