28 lines
481 B
Go
28 lines
481 B
Go
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
|
||
|
|
}
|