mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 15:09:04 +00:00
b101a7d002
Change-Id: Ib33169c3e0ffc870915c189404074a1dea472546 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196548 Reviewed-by: Bob Nystrom <rnystrom@google.com> Commit-Queue: Leaf Petersen <leafp@google.com>
55 lines
1.4 KiB
Dart
55 lines
1.4 KiB
Dart
// Copyright (c) 2013, 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.
|
|
|
|
// @dart = 2.9
|
|
|
|
import 'dart:io';
|
|
|
|
import "package:async_helper/async_helper.dart";
|
|
import "package:expect/expect.dart";
|
|
|
|
void main() {
|
|
// temp/
|
|
// a/
|
|
// file.txt
|
|
// b/
|
|
// a_link -> a
|
|
var d = Directory.systemTemp.createTempSync('dart_delete_symlink');
|
|
var a = new Directory("${d.path}/a");
|
|
a.createSync();
|
|
|
|
var b = new Directory("${d.path}/b");
|
|
b.createSync();
|
|
|
|
var f = new File("${d.path}/a/file.txt");
|
|
f.createSync();
|
|
Expect.isTrue(f.existsSync());
|
|
|
|
// Create a symlink (or junction on Windows) from
|
|
// temp/b/a_link to temp/a.
|
|
var cmd = "ln";
|
|
var args = ['-s', "${d.path}/b/a_link", "${d.path}/a"];
|
|
|
|
if (Platform.operatingSystem == "windows") {
|
|
cmd = "cmd";
|
|
args = ["/c", "mklink", "/j", "${d.path}\\b\\a_link", "${d.path}\\a"];
|
|
}
|
|
|
|
asyncStart();
|
|
|
|
Process.run(cmd, args).then((_) {
|
|
// Delete the directory containing the junction.
|
|
b.deleteSync(recursive: true);
|
|
|
|
// We should not have recursed through a_link into a.
|
|
Expect.isTrue(f.existsSync());
|
|
|
|
// Clean up after ourselves.
|
|
d.deleteSync(recursive: true);
|
|
|
|
// Terminate now that we are done with everything.
|
|
asyncEnd();
|
|
});
|
|
}
|