diff --git a/pkg/io/files/file_name_utils.go b/pkg/io/files/file_name_utils.go index 068c62f..35bd3df 100644 --- a/pkg/io/files/file_name_utils.go +++ b/pkg/io/files/file_name_utils.go @@ -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 +}