pub struct SdkPath {
pub path: PathBuf,
pub platform: Platform,
pub version: Option<SdkVersion>,
}Expand description
Represents an SDK path with metadata parsed from the path.
Fields§
§path: PathBufThe filesystem path.
platform: PlatformThe platform this SDK belongs to.
version: Option<SdkVersion>The version of the SDK.
Only present if the version occurred in the directory name. Use AppleSdk to parse SDK directories to reliably obtain the SDK version.
Implementations§
source§impl SdkPath
impl SdkPath
sourcepub fn from_path(path: impl AsRef<Path>) -> Result<Self, Error>
pub fn from_path(path: impl AsRef<Path>) -> Result<Self, Error>
Examples found in repository?
src/simple_sdk.rs (line 37)
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
fn from_directory(path: &Path) -> Result<Self, Error> {
let sdk = SdkPath::from_path(path)?;
// Need to call symlink_metadata so symlinks aren't followed.
let metadata = std::fs::symlink_metadata(path)?;
let is_symlink = metadata.file_type().is_symlink();
let json_path = path.join("SDKSettings.json");
let plist_path = path.join("SDKSettings.plist");
if json_path.exists() || plist_path.exists() {
Ok(Self {
path: path.to_path_buf(),
is_symlink,
sdk_path: sdk,
})
} else {
Err(Error::PathNotSdk(path.to_path_buf()))
}
}More examples
src/parsed_sdk.rs (line 170)
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
fn from_directory(path: &Path) -> Result<Self, Error> {
let sdk = SdkPath::from_path(path)?;
// Need to call symlink_metadata so symlinks aren't followed.
let metadata = std::fs::symlink_metadata(path)?;
let is_symlink = metadata.file_type().is_symlink();
let json_path = path.join("SDKSettings.json");
let plist_path = path.join("SDKSettings.plist");
if json_path.exists() {
let fh = std::fs::File::open(&json_path)?;
let value: SdkSettingsJson = serde_json::from_reader(fh)?;
Self::from_json(path.to_path_buf(), is_symlink, sdk.platform, value)
} else if plist_path.exists() {
let value = plist::Value::from_file(&plist_path)?;
Self::from_plist(path.to_path_buf(), is_symlink, sdk.platform, value)
} else {
Err(Error::PathNotSdk(path.to_path_buf()))
}
}