@@ -1254,16 +1254,64 @@ impl File {
12541254 }
12551255 }
12561256
1257+ #[ cfg( not( any(
1258+ target_os = "android" ,
1259+ target_os = "emscripten" ,
1260+ target_os = "fuchsia" ,
1261+ target_os = "illumos" ,
1262+ target_os = "redox" ,
1263+ target_os = "solaris"
1264+ ) ) ) ]
12571265 pub fn lock ( & self ) -> io:: Result < ( ) > {
12581266 cvt ( unsafe { libc:: flock ( self . as_raw_fd ( ) , libc:: LOCK_EX ) } ) ?;
12591267 return Ok ( ( ) ) ;
12601268 }
12611269
1270+ #[ cfg( any(
1271+ target_os = "android" ,
1272+ target_os = "emscripten" ,
1273+ target_os = "fuchsia" ,
1274+ target_os = "illumos" ,
1275+ target_os = "redox" ,
1276+ target_os = "solaris"
1277+ ) ) ]
1278+ pub fn lock ( & self ) -> io:: Result < ( ) > {
1279+ Err ( io:: const_io_error!( io:: ErrorKind :: Unsupported , "lock() not supported" ) )
1280+ }
1281+
1282+ #[ cfg( not( any(
1283+ target_os = "android" ,
1284+ target_os = "emscripten" ,
1285+ target_os = "fuchsia" ,
1286+ target_os = "illumos" ,
1287+ target_os = "redox" ,
1288+ target_os = "solaris"
1289+ ) ) ) ]
12621290 pub fn lock_shared ( & self ) -> io:: Result < ( ) > {
12631291 cvt ( unsafe { libc:: flock ( self . as_raw_fd ( ) , libc:: LOCK_SH ) } ) ?;
12641292 return Ok ( ( ) ) ;
12651293 }
12661294
1295+ #[ cfg( any(
1296+ target_os = "android" ,
1297+ target_os = "emscripten" ,
1298+ target_os = "fuchsia" ,
1299+ target_os = "illumos" ,
1300+ target_os = "redox" ,
1301+ target_os = "solaris"
1302+ ) ) ]
1303+ pub fn lock_shared ( & self ) -> io:: Result < ( ) > {
1304+ Err ( io:: const_io_error!( io:: ErrorKind :: Unsupported , "lock_shared() not supported" ) )
1305+ }
1306+
1307+ #[ cfg( not( any(
1308+ target_os = "android" ,
1309+ target_os = "emscripten" ,
1310+ target_os = "fuchsia" ,
1311+ target_os = "illumos" ,
1312+ target_os = "redox" ,
1313+ target_os = "solaris"
1314+ ) ) ) ]
12671315 pub fn try_lock ( & self ) -> io:: Result < bool > {
12681316 let result = cvt ( unsafe { libc:: flock ( self . as_raw_fd ( ) , libc:: LOCK_EX | libc:: LOCK_NB ) } ) ;
12691317 if let Err ( ref err) = result {
@@ -1275,6 +1323,26 @@ impl File {
12751323 return Ok ( true ) ;
12761324 }
12771325
1326+ #[ cfg( any(
1327+ target_os = "android" ,
1328+ target_os = "emscripten" ,
1329+ target_os = "fuchsia" ,
1330+ target_os = "illumos" ,
1331+ target_os = "redox" ,
1332+ target_os = "solaris"
1333+ ) ) ]
1334+ pub fn try_lock ( & self ) -> io:: Result < bool > {
1335+ Err ( io:: const_io_error!( io:: ErrorKind :: Unsupported , "try_lock() not supported" ) )
1336+ }
1337+
1338+ #[ cfg( not( any(
1339+ target_os = "android" ,
1340+ target_os = "emscripten" ,
1341+ target_os = "fuchsia" ,
1342+ target_os = "illumos" ,
1343+ target_os = "redox" ,
1344+ target_os = "solaris"
1345+ ) ) ) ]
12781346 pub fn try_lock_shared ( & self ) -> io:: Result < bool > {
12791347 let result = cvt ( unsafe { libc:: flock ( self . as_raw_fd ( ) , libc:: LOCK_SH | libc:: LOCK_NB ) } ) ;
12801348 if let Err ( ref err) = result {
@@ -1286,11 +1354,43 @@ impl File {
12861354 return Ok ( true ) ;
12871355 }
12881356
1357+ #[ cfg( any(
1358+ target_os = "android" ,
1359+ target_os = "emscripten" ,
1360+ target_os = "fuchsia" ,
1361+ target_os = "illumos" ,
1362+ target_os = "redox" ,
1363+ target_os = "solaris"
1364+ ) ) ]
1365+ pub fn try_lock_shared ( & self ) -> io:: Result < bool > {
1366+ Err ( io:: const_io_error!( io:: ErrorKind :: Unsupported , "try_lock_shared() not supported" ) )
1367+ }
1368+
1369+ #[ cfg( not( any(
1370+ target_os = "android" ,
1371+ target_os = "emscripten" ,
1372+ target_os = "fuchsia" ,
1373+ target_os = "illumos" ,
1374+ target_os = "redox" ,
1375+ target_os = "solaris"
1376+ ) ) ) ]
12891377 pub fn unlock ( & self ) -> io:: Result < ( ) > {
12901378 cvt ( unsafe { libc:: flock ( self . as_raw_fd ( ) , libc:: LOCK_UN ) } ) ?;
12911379 return Ok ( ( ) ) ;
12921380 }
12931381
1382+ #[ cfg( any(
1383+ target_os = "android" ,
1384+ target_os = "emscripten" ,
1385+ target_os = "fuchsia" ,
1386+ target_os = "illumos" ,
1387+ target_os = "redox" ,
1388+ target_os = "solaris"
1389+ ) ) ]
1390+ pub fn unlock ( & self ) -> io:: Result < ( ) > {
1391+ Err ( io:: const_io_error!( io:: ErrorKind :: Unsupported , "unlock() not supported" ) )
1392+ }
1393+
12941394 pub fn truncate ( & self , size : u64 ) -> io:: Result < ( ) > {
12951395 let size: off64_t =
12961396 size. try_into ( ) . map_err ( |e| io:: Error :: new ( io:: ErrorKind :: InvalidInput , e) ) ?;
0 commit comments