// Return the file's name and dir of a given path by finding the index of the last separator in the path.
// Support separators : "/" , "\\" and "\\\\"
Return the file's name and dir of a given path by finding the index of the last separator in the path.
// Return the file ' s name and dir of a given path by finding the index of the last separator in the path . // Support separators : " / " " \\ " and " \\\\ "
func GetFileAndDirFromPath(path string) (fileName, dir string) {
	index1 := strings.LastIndex(path, "/")
	index2 := strings.LastIndex(path, "\\")
	var index int
	offset := 0
	if index1 >= index2 {
		index = index1
	} else {
		index = index2
		index3 := strings.LastIndex(path, "\\\\")
		if index3 != -1 && index2-index3 == 1 {
			offset = 1
		}
	}
	if index != -1 {
		fileName = path[index+1:]
		dir = path[:index-offset]
		return
	}
	fileName = path
	dir = ""
	return
}
func GetFileAndDirFromPath ( path string ) ( fileName , dir string ) { index1 := strings . LastIndex ( path , " " ) index2 := strings . LastIndex ( path , " \\ " ) var index int offset := 0 if index1 >= index2 { index = index1 } else { index = index2 index3 := strings . LastIndex ( path , " \\ \\ " ) if index3 != - 1 && index2 - index3 == 1 { offset = 1 } } if index != - 1 { fileName = path [ index + 1 : ] dir = path [ : index - offset ] return } fileName = path dir = " " return }
Return the file's name and dir of a given path by finding the index of the last separator in the path.
Return the file ' s name and dir of a given path by finding the index of the last separator in the path .
// Check if the last separator is "\\\\" or "\\". // If the last separator is "\\\\" index will contain the index of the last "\\" , // to get the dir path (without separator suffix) we will use the offset's value.