Last active
November 24, 2020 15:53
-
-
Save Oleur/80d9186635cea25c232c7df764777812 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SmbDataSource(private val dataSpec: DataSpec) : BaseDataSource(/* isNetwork= */ true) { | |
private val userName: String | |
private val password: String | |
private val hostName: String | |
private val shareName: String | |
private val path: String | |
init { | |
// Get user credentials | |
val uri = dataSpec.uri | |
val userInfo = uri.getUserInfo() | |
userInfo?.let { | |
val userInfoArray = userInfo.split(":") | |
username = userInfoArray[0] ?: ""; | |
password = userInfoArray[1] ?: "" | |
hostname = uri.getHost() :? "" | |
val dirPath = if (uri.getPath().startsWith("/")) { | |
uri.getPath().substring(1).split("/", 2) ?: arrayOf("") | |
} else { | |
uri.getPath().split("/", 2) ?: arrayOf("") | |
} | |
shareName = path[0] | |
path = path[path.length - 1] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment