diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-10-06 17:50:00 -0400 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-10-06 17:50:00 -0400 |
commit | 64c68220d203cb07be001184cde4b35d4b503344 (patch) | |
tree | 1355846382ff21a2b1a3de606da3d9979a479dc8 /modules/git/utils.go | |
parent | 91e5c24a314170490139d661a921d94b8ab0555b (diff) | |
download | gitea-64c68220d203cb07be001184cde4b35d4b503344.tar.gz gitea-64c68220d203cb07be001184cde4b35d4b503344.zip |
Fix #264
Diffstat (limited to 'modules/git/utils.go')
-rw-r--r-- | modules/git/utils.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/modules/git/utils.go b/modules/git/utils.go index 26eef23191..6abbca557b 100644 --- a/modules/git/utils.go +++ b/modules/git/utils.go @@ -7,6 +7,7 @@ package git import ( "bytes" "container/list" + "os" "path/filepath" "strings" ) @@ -46,3 +47,23 @@ func RefEndName(refStr string) string { func filepathFromSHA1(rootdir, sha1 string) string { return filepath.Join(rootdir, "objects", sha1[:2], sha1[2:]) } + +// isDir returns true if given path is a directory, +// or returns false when it's a file or does not exist. +func isDir(dir string) bool { + f, e := os.Stat(dir) + if e != nil { + return false + } + return f.IsDir() +} + +// isFile returns true if given path is a file, +// or returns false when it's a directory or does not exist. +func isFile(filePath string) bool { + f, e := os.Stat(filePath) + if e != nil { + return false + } + return !f.IsDir() +} |