github.com/puellanivis/breton@v0.2.16/lib/files/about/schemes.go (about)

     1  package aboutfiles
     2  
     3  import (
     4  	"net/url"
     5  	"os"
     6  	"strings"
     7  	"time"
     8  
     9  	"github.com/puellanivis/breton/lib/files"
    10  	"github.com/puellanivis/breton/lib/files/wrapper"
    11  )
    12  
    13  type schemeList struct{}
    14  
    15  func (schemeList) ReadAll() ([]byte, error) {
    16  	schemes := files.RegisteredSchemes()
    17  
    18  	var lines []string
    19  
    20  	for _, scheme := range schemes {
    21  		uri := &url.URL{
    22  			Scheme: scheme,
    23  		}
    24  
    25  		lines = append(lines, uri.String())
    26  	}
    27  
    28  	return []byte(strings.Join(append(lines, ""), "\n")), nil
    29  }
    30  
    31  func (schemeList) ReadDir() ([]os.FileInfo, error) {
    32  	schemes := files.RegisteredSchemes()
    33  
    34  	var infos []os.FileInfo
    35  
    36  	for _, scheme := range schemes {
    37  		uri := &url.URL{
    38  			Scheme: scheme,
    39  		}
    40  
    41  		infos = append(infos, wrapper.NewInfo(uri, 0, time.Now()))
    42  	}
    43  
    44  	return infos, nil
    45  }