OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
Lasse Reichstein Nielsen
2015/01/08 11:59:22
2015
Søren Gjesse
2015/01/09 13:06:20
Done.
| |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 // | |
5 // Script used by the file_lock_test.dart test. | |
6 | |
7 import "dart:io"; | |
8 | |
9 main(List<String> args) { | |
10 File file = new File(args[0]); | |
11 int start = null; | |
12 int end = null; | |
13 var mode = FileLock.EXCLUSIVE; | |
Lasse Reichstein Nielsen
2015/01/08 11:59:22
Consider making arguments optional, so:
if (args
Søren Gjesse
2015/01/09 13:06:20
The test code that calls this script always passes
| |
14 if (args[1] != 'null') { | |
15 start = int.parse(args[1]); | |
16 } | |
17 if (args[2] != 'null') { | |
18 end = int.parse(args[2]); | |
19 } | |
20 if (args[3] == 'SHARED') { | |
21 mode = FileLock.SHARED; | |
22 } | |
23 var raf = file.openSync(mode: WRITE); | |
24 try { | |
25 print('calling lockSync: $start $end $mode'); | |
26 raf.lockSync(start, end, mode); | |
27 } catch (e) { | |
28 print('LOCK FAILED'); | |
29 raf.closeSync(); | |
30 return; | |
31 } | |
32 print('LOCK SUCCEEDED'); | |
33 raf.closeSync(); | |
kustermann
2015/01/08 12:54:27
move the raf.closeSync() into a finally? - then yo
Søren Gjesse
2015/01/09 13:06:20
Done.
| |
34 } | |
OLD | NEW |