WIP: Start on auto-update

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Max Brunsfeld <max@zed.dev>
Co-Authored-By: Keith Simmons <keith@zed.dev>
This commit is contained in:
Antonio Scandurra 2022-04-04 18:59:57 +02:00
parent cbf6d827db
commit 38e902b241
8 changed files with 189 additions and 20 deletions

View file

@ -623,6 +623,22 @@ impl platform::Platform for MacPlatform {
}
}
}
fn app_version(&self) -> Result<platform::AppVersion> {
unsafe {
let bundle: id = NSBundle::mainBundle();
if bundle.is_null() {
Err(anyhow!("app is not running inside a bundle"))
} else {
let version: id =
msg_send![bundle, objectForInfoDictionaryKey: "CFBundleShortVersionString"];
let len = msg_send![version, lengthOfBytesUsingEncoding: NSUTF8StringEncoding];
let bytes = version.UTF8String() as *const u8;
let version = str::from_utf8(slice::from_raw_parts(bytes, len)).unwrap();
version.parse()
}
}
}
}
unsafe fn get_foreground_platform(object: &mut Object) -> &MacForegroundPlatform {