File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -19,3 +19,4 @@ mach = "0.3"
1919audio-mixer = " 0.1"
2020ringbuf = " 0.2.6"
2121triple_buffer = " 5.0.5"
22+ plist = " 1"
Original file line number Diff line number Diff line change @@ -56,6 +56,21 @@ pub fn finally<F: FnOnce()>(f: F) -> Finalizer<F> {
5656 Finalizer ( Some ( f) )
5757}
5858
59+ pub fn os_version ( ) -> Result < String , cubeb_backend:: Error > {
60+ if let Some ( s) = plist:: Value :: from_file ( "/System/Library/CoreServices/SystemVersion.plist" )
61+ . map_err ( |e| {
62+ cubeb_log ! ( "Could not read SystemVersion.plist. Error: {}" , e) ;
63+ cubeb_backend:: Error :: error ( )
64+ } ) ?
65+ . as_dictionary ( )
66+ . and_then ( |dict| dict. get ( "ProductVersion" ) )
67+ . and_then ( |version| version. as_string ( ) )
68+ {
69+ return Ok ( s. to_string ( ) ) ;
70+ }
71+ Err ( cubeb_backend:: Error :: error ( ) )
72+ }
73+
5974#[ test]
6075fn test_forget_vec_and_retake_it ( ) {
6176 let expected: Vec < u32 > = ( 10 ..20 ) . collect ( ) ;
@@ -105,3 +120,8 @@ fn test_finally() {
105120 }
106121 assert_eq ! ( x, 100 ) ;
107122}
123+
124+ #[ test]
125+ fn test_os_version ( ) {
126+ assert ! ( !os_version( ) . unwrap( ) . is_empty( ) ) ;
127+ }
You can’t perform that action at this time.
0 commit comments