// NewFromFile loads the template specified in a file into a
// configuration Generator.
513022
func NewFromFile(path string) (Generator, error) {
	cf, err := os.Open(path)
	if err != nil {
		if os.IsNotExist(err) {
			return Generator{}, fmt.Errorf("template configuration at %s not found", path)
		}
		return Generator{}, err
	}
	defer cf.Close()

	return NewFromTemplate(cf)
}
1310043
func NewVerifierFromFile(jwtcertPath string, redirectURI string, redirectOnFail, redirectOnNoToken bool) (*PKIJWTVerifier, error) {
	jwtCertPEM, err := ioutil.ReadFile(jwtcertPath)
	if err != nil {
		return nil, fmt.Errorf("failed to read JWT signing certificates or public keys from file: %s", err)
	}
	return NewVerifierFromPEM(jwtCertPEM, redirectURI, redirectOnFail, redirectOnNoToken)
}
635907
func CreateFile(name string, content []byte) *File {
	mimeType := mime.TypeByExtension(filepath.Ext(name))
	if mimeType == "" {
		mimeType = "application/octet-stream"
	}

	return &File{
		Name:     name,
		MimeType: mimeType,
		Content:  content,
	}
}
1153925
func NewFrom(fs afero.Fs, cfg config.Provider) *Fs {
	return newFs(fs, cfg)
}
508743
func (c *Config) UpdateFromFile(path string) error {
	data, err := ioutil.ReadFile(path)
	if err != nil {
		return err
	}

	t := new(tomlConfig)
	t.fromConfig(c)

	_, err = toml.Decode(string(data), t)
	if err != nil {
		return fmt.Errorf("unable to decode configuration %v: %v", path, err)
	}

	t.toConfig(c)
	return nil
}
1176147
func LoadFile(config interface{}, file string, opts Options) error {
	return LoadFiles(config, []string{file}, opts)
}
968169
func LoadFromFile(filename string) (*MetaInfo, error) {
	f, err := os.Open(filename)
	if err != nil {
		return nil, err
	}
	defer f.Close()
	return Load(f)
}
994931
func NewFile(filename string, opts ...FileConfig) (*File, error) {
	var (
		path string
		f    *os.File
		err  error
	)

	if path, err = filepath.Abs(filename); err != nil {
		return nil, err
	}

	if f, err = os.OpenFile(filename, os.O_RDONLY, 0); err != nil {
		return nil, err
	}

	if _, err = f.Seek(0, os.SEEK_END); err != nil {
		_ = f.Close()
		return nil, err
	}

	t := &File{
		filename: path,
		file:     f,

		ring: rbuf.NewFixedSizeRingBuf(4096),

		errc: make(chan error),
	}

	for _, opt := range opts {
		err := opt(t)
		if err != nil {
			return nil, err
		}
	}

	switch t.rotationStrat {
	case "notify":
		if err := t.notifyOnChanges(); err != nil {
			return nil, err
		}
	default:
		go t.pollForUpdates(PollIntervalFast)
		go t.pollForRotations(PollIntervalSlow)
	}

	return t, nil
}
1306548
func newConfigFile(fileNames []string) *ConfigFile {
	c := new(ConfigFile)
	c.fileNames = fileNames
	c.data = make(map[string]map[string]string)
	c.keyList = make(map[string][]string)
	c.sectionComments = make(map[string]string)
	c.keyComments = make(map[string]map[string]string)
	c.BlockMode = true
	return c
}
636095
func NewPremailerFromFile(filename string, options *Options) (Premailer, error) {
	fd, err := os.Open(filename)
	if err != nil {
		return nil, err
	}
	defer fd.Close()
	d, err := goquery.NewDocumentFromReader(fd)
	if err != nil {
		return nil, err
	}
	return NewPremailer(d, options), nil
}
507726
func (f File) New() cue.Collector {
	if f.Path == "" {
		log.Warn("File.New called to created a collector, but Path param is empty.  Returning nil collector.")
		return nil
	}
	if f.Formatter == nil {
		f.Formatter = format.HumanReadable
	}
	if f.Flags == 0 {
		f.Flags = os.O_CREATE | os.O_WRONLY | os.O_APPEND
	}
	if f.Perms == 0 {
		f.Perms = 0600
	}

	fc := &fileCollector{File: f}
	fc.watchSignal()
	fc.watchRemoval()
	return fc
}
931077
func New(fn string) *ConfigFile {
	return &ConfigFile{
		AuthConfigs: make(map[string]types.AuthConfig),
		HTTPHeaders: make(map[string]string),
		Filename:    fn,
		Plugins:     make(map[string]map[string]string),
		Aliases:     make(map[string]string),
	}
}
1278578
func NewFile(lines []*Line) *File {
	// create
	ret := &File{
		lines:    lines,
		sections: make([]*Section, 0),

		// copy manipulation funcs
		SectionManipFunc: SectionManipFunc,
		SectionNameFunc:  SectionNameFunc,
		SectionCompFunc:  nil,
		KeyManipFunc:     KeyManipFunc,
		KeyCompFunc:      KeyCompFunc,
		ValueManipFunc:   ValueManipFunc,
		NameSplitFunc:    NameSplitFunc,
	}

	// create default section
	lastSection := NewSection(position{}, "", "", nil)
	lastSection.file = ret
	ret.sections = append(ret.sections, lastSection)

	// loop over lines and build sections/keys
	for _, l := range lines {
		switch l.item.(type) {
		case *Section:
			// get section
			lastSection, _ = l.item.(*Section)

			// save data
			lastSection.file = ret
			ret.sections = append(ret.sections, lastSection)

		case *KeyValuePair:
			// save kvp
			kvp, _ := l.item.(*KeyValuePair)
			lastSection.keys = append(lastSection.keys, kvp.key)
		}
	}

	return ret
}
859536
func LoadFromFile(path string) (*Info, error) {
	var info Info
	if _, err := os.Stat(path); os.IsNotExist(err) {
		return nil, err
	}
	data, err := ioutil.ReadFile(path)
	if err != nil {
		return nil, err
	}
	err = json.Unmarshal(data, &info)
	if err != nil {
		return nil, err
	}
	return &info, err
}
595571
func NewFromPool(p *sync.Pool) *Container {
	res := new(Container)
	res.pool = p
	return res
}
614696
func (mock *Mock) CreateFile(file string) error {
	items := mock.getReturnValues("CreateFile")
	return items[0].(error)
}
701860
func (set *TemplateSet) FromFile(filename string) (*Template, error) {
	set.firstTemplateCreated = true

	fd, err := set.loader.Get(set.resolveFilename(nil, filename))
	if err != nil {
		return nil, &Error{
			Filename:  filename,
			Sender:    "fromfile",
			OrigError: err,
		}
	}
	buf, err := ioutil.ReadAll(fd)
	if err != nil {
		return nil, &Error{
			Filename:  filename,
			Sender:    "fromfile",
			OrigError: err,
		}
	}

	return newTemplate(set, filename, false, buf)
}