示例#1
0
func isPathWriteable(p gopath.GoPath) bool {
	if p.IsDirectory() {
		return isDirWriteable(p)
	}

	return isFileWriteable(p)
}
示例#2
0
文件: mimeDetector.go 项目: fxnn/gone
func (m *mimeDetector) mimeTypeForPath(p gopath.GoPath) string {
	p = p.EvalSymlinks()
	if p.IsDirectory() || p.HasErr() {
		return store.FallbackMimeType
	}

	var ext = p.Ext()
	if mimeType := mime.TypeByExtension(ext); mimeType != "" {
		return mimeType
	}

	var first512Bytes = m.first512BytesForPath(p)
	m.errAndClear() // clear error flag, as DetectContentType always returns something

	return http.DetectContentType(first512Bytes)
}
示例#3
0
func (a *accessControl) canWriteDirectory(p gopath.GoPath) bool {
	if p.HasErr() || !p.IsDirectory() {
		return false
	}
	return a.hasWorldWritePermission(p.FileMode())
}