feature: added file path restricted characters replacements

master
amorozov 2024-06-25 13:24:58 +03:00
parent c97d758a6a
commit 85f15eee46
1 changed files with 20 additions and 0 deletions

View File

@ -8,6 +8,18 @@ import (
"git.tswf.io/incredible-go/incredible-go-core/pkg/collections/array_list"
)
var RestrictedFilepathCharactersReplacements = map[string]string{
"<": "",
">": "",
":": "",
"\"": "",
"/": "",
"\\": "",
"|": "",
"?": "",
"*": "",
}
func GetSimpleName(filePath string) string {
return SplitFileName(filePath).GetLast()
}
@ -36,3 +48,11 @@ func SplitFileName(filePath string) *array_list.ArrayList[string] {
return array_list.NewArrayListWithContent[string](split...)
}
func ReplaceAllRestrictedCharacters(filePath string) string {
for k, v := range RestrictedFilepathCharactersReplacements {
filePath = strings.ReplaceAll(filePath, k, v)
}
return filePath
}