forked from dart-lang/co19
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dart-lang#2291. Update
Link.createSync()
according to the new docum…
…entation. Part 1
- Loading branch information
Showing
29 changed files
with
1,164 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion void createSync( | ||
/// String target, | ||
/// {bool recursive = false} | ||
/// ) | ||
/// Synchronously create the link. Calling createSync on an existing link will | ||
/// throw an exception. | ||
/// | ||
/// If recursive is false, the default, the link is created only if all | ||
/// directories in its path exist. If recursive is true, all non-existing parent | ||
/// paths are created first. The directories in the path of target are not | ||
/// affected, unless they are also in path. | ||
/// | ||
/// On the Windows platform, this call will create a true symbolic link instead | ||
/// of a junction. The link represents a file or directory and does not change | ||
/// its type after creation. If [target] exists then the type of the link will | ||
/// match the type [target], otherwise a file symlink is created. | ||
/// | ||
/// In order to create a symbolic link on Windows, Dart must be run in | ||
/// Administrator mode or the system must have Developer Mode enabled, | ||
/// otherwise a [FileSystemException] will be raised with | ||
/// `ERROR_PRIVILEGE_NOT_HELD` set as the errno when this call is made. | ||
/// | ||
/// On other platforms, the POSIX symlink() call is used to make a symbolic link | ||
/// containing the string target. If target is a relative path, it will be | ||
/// interpreted relative to the directory containing the link. | ||
/// | ||
/// @description Checks that this method creates the link. Test [File] as a | ||
/// target | ||
/// @author sgrekhov22@gmail.com | ||
import "dart:io"; | ||
import "../../../Utils/expect.dart"; | ||
import "../file_utils.dart"; | ||
|
||
main() async { | ||
await inSandbox(_main); | ||
} | ||
|
||
_main(Directory sandbox) async { | ||
File target = getTempFileSync(parent: sandbox); | ||
Link link = new Link(getTempFilePath(parent: sandbox)); | ||
link.createSync(target.path); | ||
Expect.isTrue(link.existsSync()); | ||
Expect.equals(target.path, link.targetSync()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion void createSync( | ||
/// String target, | ||
/// {bool recursive = false} | ||
/// ) | ||
/// Synchronously create the link. Calling createSync on an existing link will | ||
/// throw an exception. | ||
/// | ||
/// If recursive is false, the default, the link is created only if all | ||
/// directories in its path exist. If recursive is true, all non-existing parent | ||
/// paths are created first. The directories in the path of target are not | ||
/// affected, unless they are also in path. | ||
/// | ||
/// On the Windows platform, this call will create a true symbolic link instead | ||
/// of a junction. The link represents a file or directory and does not change | ||
/// its type after creation. If [target] exists then the type of the link will | ||
/// match the type [target], otherwise a file symlink is created. | ||
/// | ||
/// In order to create a symbolic link on Windows, Dart must be run in | ||
/// Administrator mode or the system must have Developer Mode enabled, | ||
/// otherwise a [FileSystemException] will be raised with | ||
/// `ERROR_PRIVILEGE_NOT_HELD` set as the errno when this call is made. | ||
/// | ||
/// On other platforms, the POSIX symlink() call is used to make a symbolic link | ||
/// containing the string target. If target is a relative path, it will be | ||
/// interpreted relative to the directory containing the link. | ||
/// | ||
/// @description Checks that this method creates the link. Test another [Link] | ||
/// as a target | ||
/// @author sgrekhov22@gmail.com | ||
import "dart:io"; | ||
import "../../../Utils/expect.dart"; | ||
import "../file_utils.dart"; | ||
|
||
main() async { | ||
await inSandbox(_main); | ||
} | ||
|
||
_main(Directory sandbox) async { | ||
Link target = getTempLinkSync(parent: sandbox, target: sandbox.path); | ||
Link link = new Link(getTempFilePath(parent: sandbox)); | ||
link.createSync(target.path); | ||
Expect.isTrue(link.existsSync()); | ||
Expect.equals(target.path, link.targetSync()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion void createSync( | ||
/// String target, | ||
/// {bool recursive = false} | ||
/// ) | ||
/// Synchronously create the link. Calling createSync on an existing link will | ||
/// throw an exception. | ||
/// | ||
/// If recursive is false, the default, the link is created only if all | ||
/// directories in its path exist. If recursive is true, all non-existing parent | ||
/// paths are created first. The directories in the path of target are not | ||
/// affected, unless they are also in path. | ||
/// | ||
/// On the Windows platform, this call will create a true symbolic link instead | ||
/// of a junction. The link represents a file or directory and does not change | ||
/// its type after creation. If [target] exists then the type of the link will | ||
/// match the type [target], otherwise a file symlink is created. | ||
/// | ||
/// In order to create a symbolic link on Windows, Dart must be run in | ||
/// Administrator mode or the system must have Developer Mode enabled, | ||
/// otherwise a [FileSystemException] will be raised with | ||
/// `ERROR_PRIVILEGE_NOT_HELD` set as the errno when this call is made. | ||
/// | ||
/// On other platforms, the POSIX symlink() call is used to make a symbolic link | ||
/// containing the string target. If target is a relative path, it will be | ||
/// interpreted relative to the directory containing the link. | ||
/// | ||
/// @description Checks that this method creates the link. Test not existing | ||
/// entity as a target | ||
/// @author sgrekhov22@gmail.com | ||
import "dart:io"; | ||
import "../../../Utils/expect.dart"; | ||
import "../file_utils.dart"; | ||
|
||
main() async { | ||
await inSandbox(_main); | ||
} | ||
|
||
_main(Directory sandbox) async { | ||
String target = getTempFilePath(parent: sandbox); | ||
Link link = new Link(getTempFilePath(parent: sandbox)); | ||
link.createSync(target); | ||
Expect.isTrue(link.existsSync()); | ||
Expect.equals(target, link.targetSync()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.