Combines a base path with an optional raw name (which may contain unsafe characters),
sanitizes the name if provided, ensures the directory exists, and returns the full path.
Parameters
basePath: string
Parent path
Optionalname: string
Optional raw folder name (can contain unsafe characters)
Combines a base path with an optional raw name (which may contain unsafe characters), sanitizes the name if provided, ensures the directory exists, and returns the full path.