48e5cba6b9
This reverts commit f8fbefd951 in patchset 1 with fixes to the way how temporary strings are allocated and the way how prefixed string is returned in successive patchsets.
Fixes https://github.com/dart-lang/sdk/issues/42416
Change-Id: Idb801cb117fc2d84fad4c533f5239d8499afc943
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164741
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
40 lines
1.2 KiB
Dart
40 lines
1.2 KiB
Dart
// Copyright (c) 2020, 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.
|
|
//
|
|
// This test is Windows-only. It tests a short (shorter than 260) relative path
|
|
// representing a long absolute path cannot be used by Windows API. Running this
|
|
// test without proper support on long path will get an error.
|
|
|
|
import 'dart:io';
|
|
|
|
const maxPath = 260;
|
|
|
|
void main(args) {
|
|
if (!Platform.isWindows) {
|
|
return;
|
|
}
|
|
final dir = Directory.systemTemp.createTempSync('test');
|
|
|
|
if (dir.path.length >= maxPath) {
|
|
return;
|
|
}
|
|
|
|
// Make sure oldpath is shorter than MAX_PATH (260).
|
|
int length = (maxPath - dir.path.length) ~/ 2;
|
|
final oldpath = Directory('${dir.path}\\${'x' * length}}');
|
|
oldpath.createSync(recursive: true);
|
|
final temp = Directory.current;
|
|
|
|
Directory.current = oldpath.path;
|
|
|
|
// The length of relative path is always shorter than maxPath, but it
|
|
// represents a path exceeding the maxPath.
|
|
final newpath = Directory('.\\${'y' * 2 * length}');
|
|
newpath.createSync();
|
|
|
|
// Reset current directory before deletion.
|
|
Directory.current = temp.path;
|
|
dir.deleteSync(recursive: true);
|
|
}
|