initial commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package sqan
|
||||
|
||||
import "strings"
|
||||
|
||||
func ParsePath(rootDir, absPath string) (relPath, relDir, filename, extension string) {
|
||||
if absPath[0:len(rootDir)] != rootDir {
|
||||
return
|
||||
}
|
||||
|
||||
relPath = absPath[len(rootDir):]
|
||||
|
||||
if i := strings.LastIndexByte(relPath, '/'); i > -1 {
|
||||
if i > 0 {
|
||||
relDir = relPath[0:i]
|
||||
} else {
|
||||
relDir = "/"
|
||||
}
|
||||
|
||||
filename = relPath[i+1:]
|
||||
}
|
||||
|
||||
if i := strings.LastIndexByte(filename, '.'); i > -1 {
|
||||
extension = strings.ToLower(filename[i+1:])
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user