You've already forked filebrowser
mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-11-26 14:25:26 +08:00
close #11
This commit is contained in:
@@ -2,8 +2,10 @@ package utils
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
"text/template"
|
||||
@@ -12,6 +14,30 @@ import (
|
||||
"github.com/hacdias/caddy-hugo/assets"
|
||||
)
|
||||
|
||||
// CopyFile is used to copy a file
|
||||
func CopyFile(old, new string) error {
|
||||
// Open the file and create a new one
|
||||
r, err := os.Open(old)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer r.Close()
|
||||
|
||||
w, err := os.Create(new)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer w.Close()
|
||||
|
||||
// Copy the content
|
||||
_, err = io.Copy(w, r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CanBeEdited checks if a filename has a supported extension
|
||||
func CanBeEdited(filename string) bool {
|
||||
extensions := [...]string{".markdown", ".md",
|
||||
|
||||
Reference in New Issue
Block a user