return len(s) >= len(prefix) && s[0:len(prefix)] == prefix
}
-// LastIndexByte from the strings package.
-func lastIndex(s string, sep byte) int {
- for i := len(s) - 1; i >= 0; i-- {
- if s[i] == sep {
- return i
- }
- }
- return -1
-}
-
func rename(oldname, newname string) error {
dirname := oldname[:lastIndex(oldname, '/')+1]
if hasPrefix(newname, dirname) {
package os
-import (
- "errors"
- "strings"
-)
+import "errors"
// fastrand provided by runtime.
// We generate random temporary file names so that there's a good
return "", "", errPatternHasSeparator
}
}
- if pos := strings.LastIndex(pattern, "*"); pos != -1 {
+ if pos := lastIndex(pattern, '*'); pos != -1 {
prefix, suffix = pattern[:pos], pattern[pos+1:]
} else {
prefix = pattern
}
return dir + string(PathSeparator) + name
}
+
+// LastIndexByte from the strings package.
+func lastIndex(s string, sep byte) int {
+ for i := len(s) - 1; i >= 0; i-- {
+ if s[i] == sep {
+ return i
+ }
+ }
+ return -1
+}