aboutsummaryrefslogtreecommitdiff
path: root/fileutils.go
diff options
context:
space:
mode:
Diffstat (limited to 'fileutils.go')
-rw-r--r--fileutils.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/fileutils.go b/fileutils.go
new file mode 100644
index 0000000..03e71fb
--- /dev/null
+++ b/fileutils.go
@@ -0,0 +1,30 @@
+package main
+
+import (
+ "mime"
+ "os"
+ "path/filepath"
+)
+
+func absPathMime(path string) string {
+ ext := filepath.Ext(path)
+ return mime.TypeByExtension(ext)
+}
+
+func isFile(path string) bool {
+ fileInfo, err := os.Stat(path)
+ if err != nil {
+ return false
+ }
+
+ return fileInfo.Mode().IsRegular()
+}
+
+func isExecutable(path string) bool {
+ stat, err := os.Stat(path)
+ if err != nil {
+ return false
+ }
+
+ return stat.Mode().Perm()&0111 == 0111
+}