file

package
v0.0.0-...-7057679 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2016 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	os.FileInfo
	URL         string
	Path        string // Relative path to Caddyfile
	VirtualPath string // Relative path to u.FileSystem
	Mimetype    string
	Content     []byte
	Type        string
	UserAllowed bool // Indicates if the user has enough permissions
}

Info contains the information about a particular file or directory

func GetInfo

func GetInfo(url *url.URL, c *config.Config, u *config.User) (*Info, int, error)

GetInfo gets the file information and, in case of error, returns the respective HTTP error code

func (Info) CanBeEdited

func (i Info) CanBeEdited() bool

CanBeEdited checks if the extension of a file is supported by the editor

func (Info) HumanModTime

func (i Info) HumanModTime(format string) string

HumanModTime returns the modified time of the file as a human-readable string.

func (Info) HumanSize

func (i Info) HumanSize() string

HumanSize returns the size of the file as a human-readable string in IEC format (i.e. power of 2 or base 1024).

func (*Info) Read

func (i *Info) Read() error

Reads the file.

func (*Info) RetrieveFileType

func (i *Info) RetrieveFileType() error

RetrieveFileType obtains the mimetype and a simplified internal Type using the first 512 bytes from the file.

func (Info) StringifyContent

func (i Info) StringifyContent() string

StringifyContent returns the string version of Raw

type Listing

type Listing struct {
	// The name of the directory (the last element of the path)
	Name string
	// The full path of the request relatively to a File System
	Path string
	// The items (files and folders) in the path
	Items []Info
	// The number of directories in the listing
	NumDirs int
	// The number of files (items that aren't directories) in the listing
	NumFiles int
	// Which sorting order is used
	Sort string
	// And which order
	Order string
	// If ≠0 then Items have been limited to that many elements
	ItemsLimitedTo     int
	httpserver.Context `json:"-"`
}

A Listing is the context used to fill out a template.

func GetListing

func GetListing(u *config.User, filePath string, baseURL string) (*Listing, error)

GetListing gets the information about a specific directory and its files.

func (Listing) ApplySort

func (l Listing) ApplySort()

ApplySort applies the sort order using .Order and .Sort

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL