// NewFileStorage creates a new temp file that will be used as a the storage of the cache entry
542786
func NewFileStorage(path string) (ResponseStorage, error) {
	file, err := ioutil.TempFile(path, "caddy-cache-")
	if err != nil {
		return nil, err
	}
	return &FileStorage{
		file:         file,
		subscription: NewSubscription(),
	}, nil
}
914820
func NewStorage(fs billy.Filesystem, cache cache.Object) *Storage {
	return NewStorageWithOptions(fs, cache, Options{})
}
1067630
func NewStorage(file string) (sorted.KeyValue, error) {
	return newKeyValueFromJSONConfig(jsonconfig.Obj{"file": file})
}
1124330
func NewDisk(policies Policies, path, namespace string) (Cache, error) {
	if !filepath.IsAbs(path) {
		return nil, errors.New("must use absolute path")
	}
	d := &disk{
		policies: policies,
		path:     path,
		h:        isolated.GetHash(namespace),
		lru:      makeLRUDict(namespace),
	}
	p := d.statePath()
	f, err := os.Open(p)
	if err == nil {
		defer f.Close()
		err = json.NewDecoder(f).Decode(&d.lru)
	} else if os.IsNotExist(err) {
		// The fact that the cache is new is not an error.
		err = nil
	}
	return d, err
}
835811
func New(config Config) (ExpirableStorage, error) {
	if err := config.Validate(); err != nil {
		return nil, errors.Annotate(err, "validating config")
	}
	return &storage{
		config:   config,
		rootKeys: mgostorage.NewRootKeys(5),
	}, nil
}
383140
func NewFileStorage(dir string) (Storage, error) {
	path, err := filepath.Abs(dir)
	if err != nil {
		return nil, err
	}

	// Why 0777?
	// Read http://unix.stackexchange.com/questions/21251/why-do-directories-need-the-executable-x-permission-to-be-opened
	err = os.MkdirAll(path, 0777)
	return &fileStorage{dirPath: path}, err
}
1892
func NewFileSystemAPIServer(store store.GroupStore) *FileSystemAPIServer {
	s := new(FileSystemAPIServer)
	s.gstore = store
	return s
}
1162882
func NewFile(N int64, file File) BufferAt {
	return &fileBuffer{
		file:    file,
		Wrapper: wrapio.NewWrapper(file, 0, 0, N),
	}
}
547373
func NewCacheLoader(files []string) *CacheLoader {
	return &CacheLoader{
		files:  files,
		Logger: zap.NewNop(),
	}
}
875554
func NewFileStore(baseDir, fileExt string) (*FilesystemStore, error) {
	baseDir = filepath.Clean(baseDir)
	if err := createDirectory(baseDir, notary.PrivExecPerms); err != nil {
		return nil, err
	}
	if !strings.HasPrefix(fileExt, ".") {
		fileExt = "." + fileExt
	}

	return &FilesystemStore{
		baseDir: baseDir,
		ext:     fileExt,
	}, nil
}
759138
func NewFileStorageReader(path string) (reader storage.StorageReader, err error) {
	var p string
	if p, err = utils.NormalizePath(path); err != nil {
		return nil, err
	}
	if p, err = filepath.Abs(p); err != nil {
		return nil, err
	}
	fi, err := os.Stat(p)
	if err != nil {
		return nil, err
	}
	if !fi.Mode().IsDir() {
		return nil, fmt.Errorf("specified source path is not a directory: %s", path)
	}
	return &fileStorageReader{p}, nil
}
411727
func TemporaryFile(scratchDir string, name string) (*os.File, error) {
	workingDir, err := os.Getwd()
	if nil != err {
		return nil, err
	}

	// Use a stable temporary name
	temporaryPath := filepath.Join(workingDir, scratchDir, name)
	buildDir := filepath.Dir(temporaryPath)
	mkdirErr := os.MkdirAll(buildDir, os.ModePerm)
	if nil != mkdirErr {
		return nil, mkdirErr
	}

	tmpFile, err := os.Create(temporaryPath)
	if err != nil {
		return nil, errors.New("Failed to create temporary file: " + err.Error())
	}

	return tmpFile, nil
}
971108
func NewDiskCache(baseDir string) (*DiskCache, error) {
	err := os.MkdirAll(baseDir, 0700)
	if err != nil {
		return nil, err
	}
	return &DiskCache{baseDir: baseDir, fileList: make(map[string]int)}, nil
}
757785
func NewCSVStorage(rw io.ReadWriter) (Storage, error) {
	cs := &csvStorage{
		w:     csv.NewWriter(rw),
		cache: NewMemoryStorage(),
	}
	if err := readCSV(cs.cache, rw); err != nil {
		return nil, err
	}
	return cs, nil
}
218554
func NewCachedStorage(backend KeyPairStorage, cache KeyPairStorage) *CachedStorage {
	return &CachedStorage{
		cache:   cache,
		backend: backend,
	}
}
968590
func New(dir string) (blobserver.Storage, error) {
	var maxSize int64
	if ok, _ := IsDir(dir); ok {
		// TODO: detect existing max size from size of files, if obvious,
		// and set maxSize to that?
	}
	return newStorage(dir, maxSize, nil)
}
85281
func NewReferenceStorage(base, temporal storer.ReferenceStorer) *ReferenceStorage {
	return &ReferenceStorage{
		ReferenceStorer: base,
		temporal:        temporal,

		deleted: make(map[plumbing.ReferenceName]struct{}, 0),
	}
}