feature: added file path restricted characters replacements
parent
c97d758a6a
commit
85f15eee46
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue