@@ -1254,16 +1254,64 @@ impl File {
1254
1254
}
1255
1255
}
1256
1256
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
+ ) ) ) ]
1257
1265
pub fn lock ( & self ) -> io:: Result < ( ) > {
1258
1266
cvt ( unsafe { libc:: flock ( self . as_raw_fd ( ) , libc:: LOCK_EX ) } ) ?;
1259
1267
return Ok ( ( ) ) ;
1260
1268
}
1261
1269
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
+ ) ) ) ]
1262
1290
pub fn lock_shared ( & self ) -> io:: Result < ( ) > {
1263
1291
cvt ( unsafe { libc:: flock ( self . as_raw_fd ( ) , libc:: LOCK_SH ) } ) ?;
1264
1292
return Ok ( ( ) ) ;
1265
1293
}
1266
1294
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
+ ) ) ) ]
1267
1315
pub fn try_lock ( & self ) -> io:: Result < bool > {
1268
1316
let result = cvt ( unsafe { libc:: flock ( self . as_raw_fd ( ) , libc:: LOCK_EX | libc:: LOCK_NB ) } ) ;
1269
1317
if let Err ( ref err) = result {
@@ -1275,6 +1323,26 @@ impl File {
1275
1323
return Ok ( true ) ;
1276
1324
}
1277
1325
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
+ ) ) ) ]
1278
1346
pub fn try_lock_shared ( & self ) -> io:: Result < bool > {
1279
1347
let result = cvt ( unsafe { libc:: flock ( self . as_raw_fd ( ) , libc:: LOCK_SH | libc:: LOCK_NB ) } ) ;
1280
1348
if let Err ( ref err) = result {
@@ -1286,11 +1354,43 @@ impl File {
1286
1354
return Ok ( true ) ;
1287
1355
}
1288
1356
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
+ ) ) ) ]
1289
1377
pub fn unlock ( & self ) -> io:: Result < ( ) > {
1290
1378
cvt ( unsafe { libc:: flock ( self . as_raw_fd ( ) , libc:: LOCK_UN ) } ) ?;
1291
1379
return Ok ( ( ) ) ;
1292
1380
}
1293
1381
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
+
1294
1394
pub fn truncate ( & self , size : u64 ) -> io:: Result < ( ) > {
1295
1395
let size: off64_t =
1296
1396
size. try_into ( ) . map_err ( |e| io:: Error :: new ( io:: ErrorKind :: InvalidInput , e) ) ?;
0 commit comments