sgrekhov | ad64950 | 2021-05-05 13:24:59 +0700 | [diff] [blame] | 1 | // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 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 | |
sgrekhov | ae517f5 | 2021-05-05 17:05:19 +0700 | [diff] [blame] | 5 | // @dart = 2.9 |
| 6 | |
sgrekhov | ad64950 | 2021-05-05 13:24:59 +0700 | [diff] [blame] | 7 | /// @assertion bool identicalSync( |
| 8 | /// String path1, |
| 9 | /// String path2 |
| 10 | /// ) |
| 11 | /// Synchronously checks whether two paths refer to the same object in the file |
| 12 | /// system. |
| 13 | /// |
| 14 | /// Comparing a link to its target returns false, as does comparing two links |
| 15 | /// that point to the same target. To check the target of a link, use Link.target |
| 16 | /// explicitly to fetch it. Directory links appearing inside a path are followed, |
| 17 | /// though, to find the file system object. |
| 18 | /// |
| 19 | /// Throws an error if one of the paths points to an object that does not exist. |
| 20 | /// @description Checks that this method completes with true if two paths refer |
| 21 | /// to the same object in the file system. Test Test relative paths for file |
| 22 | /// @author sgrekhov@unipro.ru |
| 23 | |
Sergey G. Grekhov | 45dcc9d | 2018-10-08 16:17:23 +0700 | [diff] [blame] | 24 | import "dart:io"; |
| 25 | import "../../../Utils/expect.dart"; |
| 26 | import "../file_utils.dart"; |
| 27 | |
Sergey G. Grekhov | 5099a46 | 2018-11-13 11:06:34 +0700 | [diff] [blame] | 28 | main() async { |
| 29 | Directory sandbox = getTempDirectorySync(parent: Directory.current); |
| 30 | await inSandbox(_main, sandbox: sandbox); |
| 31 | } |
| 32 | |
| 33 | _main(Directory sandbox) async { |
Sergey G. Grekhov | 45dcc9d | 2018-10-08 16:17:23 +0700 | [diff] [blame] | 34 | String fileName = getTempFileName(); |
Sergey G. Grekhov | 5099a46 | 2018-11-13 11:06:34 +0700 | [diff] [blame] | 35 | File file = new File(sandbox.path + Platform.pathSeparator + fileName); |
Sergey G. Grekhov | 45dcc9d | 2018-10-08 16:17:23 +0700 | [diff] [blame] | 36 | file.createSync(); |
Sergey G. Grekhov | 5099a46 | 2018-11-13 11:06:34 +0700 | [diff] [blame] | 37 | Expect.isTrue(FileSystemEntity.identicalSync( |
| 38 | getEntityName(sandbox) + Platform.pathSeparator + fileName, |
| 39 | getEntityName(sandbox) + Platform.pathSeparator + fileName)); |
Sergey G. Grekhov | 45dcc9d | 2018-10-08 16:17:23 +0700 | [diff] [blame] | 40 | } |