blob: 08a5f267619a253085fe83478d35d0f7b54f7b9a [file] [log] [blame]
sgrekhovad649502021-05-05 13:24:59 +07001// 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
sgrekhovae517f52021-05-05 17:05:19 +07005// @dart = 2.9
6
sgrekhovad649502021-05-05 13:24:59 +07007/// @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. Grekhov45dcc9d2018-10-08 16:17:23 +070024import "dart:io";
25import "../../../Utils/expect.dart";
26import "../file_utils.dart";
27
Sergey G. Grekhov5099a462018-11-13 11:06:34 +070028main() async {
29 Directory sandbox = getTempDirectorySync(parent: Directory.current);
30 await inSandbox(_main, sandbox: sandbox);
31}
32
33_main(Directory sandbox) async {
Sergey G. Grekhov45dcc9d2018-10-08 16:17:23 +070034 String fileName = getTempFileName();
Sergey G. Grekhov5099a462018-11-13 11:06:34 +070035 File file = new File(sandbox.path + Platform.pathSeparator + fileName);
Sergey G. Grekhov45dcc9d2018-10-08 16:17:23 +070036 file.createSync();
Sergey G. Grekhov5099a462018-11-13 11:06:34 +070037 Expect.isTrue(FileSystemEntity.identicalSync(
38 getEntityName(sandbox) + Platform.pathSeparator + fileName,
39 getEntityName(sandbox) + Platform.pathSeparator + fileName));
Sergey G. Grekhov45dcc9d2018-10-08 16:17:23 +070040}