github.com/matthewmueller/go-archive@v1.0.3-0.20180913190615-0f8ce9f192c4/archive_info.go (about)

     1  package archive
     2  
     3  import (
     4  	"os"
     5  	"time"
     6  )
     7  
     8  // pathInfo wraps FileInfo to support a full path
     9  // in place of Name(), which just makes the API
    10  // a little simpler.
    11  type pathInfo struct {
    12  	os.FileInfo
    13  	path string
    14  }
    15  
    16  // Name returns the full path.
    17  func (p *pathInfo) Name() string {
    18  	return p.path
    19  }
    20  
    21  // FileInfo implements the os.FileInfo interface,
    22  // and is useful if you're working with
    23  // in-memory contents instead of files
    24  // from disk.
    25  type FileInfo struct {
    26  	Info
    27  }
    28  
    29  // Name implementation.
    30  func (i *FileInfo) Name() string {
    31  	return i.Info.Name
    32  }
    33  
    34  // Size implementation.
    35  func (i *FileInfo) Size() int64 {
    36  	return i.Info.Size
    37  }
    38  
    39  // Mode implementation.
    40  func (i *FileInfo) Mode() os.FileMode {
    41  	return i.Info.Mode
    42  }
    43  
    44  // ModTime implementation.
    45  func (i *FileInfo) ModTime() time.Time {
    46  	return i.Info.Modified
    47  }
    48  
    49  // IsDir implementation.
    50  func (i *FileInfo) IsDir() bool {
    51  	return i.Info.Dir
    52  }
    53  
    54  // Sys implementation.
    55  func (i *FileInfo) Sys() interface{} {
    56  	return nil
    57  }
    58  
    59  // Info implements the os.FileInfo interface,
    60  // and is useful if you're working with
    61  // in-memory contents instead of files
    62  // from disk.
    63  type Info struct {
    64  	Name     string
    65  	Size     int64
    66  	Mode     os.FileMode
    67  	Modified time.Time
    68  	Dir      bool
    69  }
    70  
    71  // FileInfo returns the info wrapped as an os.FileInfo.
    72  func (i Info) FileInfo() os.FileInfo {
    73  	return &FileInfo{i}
    74  }