all repos — fsrv @ b0805af60f2c59885ce9aaf44dc935a5ff6b3eed

filehost server for x.icyphox.sh

fs.go (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
package main

import (
	"net/http"
	"os"
)

type nodirFileSystem struct {
	fs http.FileSystem
}

func (nd nodirFileSystem) Open(path string) (http.File, error) {
	f, err := nd.fs.Open(path)
	if err != nil {
		return nil, err
	}

	s, err := f.Stat()
	if s.IsDir() {
		return nil, os.ErrNotExist
	}

	return f, nil
}