platform_helper.dart 566 Bytes
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
// @dart = 2.8

7 8 9 10 11 12 13 14 15 16 17 18 19 20
import 'dart:io' show Platform;

/// Returns [Platform.pathSeparator], suitably escaped so as to be usable in a
/// regular expression.
String get pathSeparatorForRegExp {
  switch (Platform.pathSeparator) {
    case r'/':
      return r'/';
    case r'\':
      return r'\\'; // because dividerRegExp gets inserted into regexps
    default:
      throw 'Unsupported platform.';
  }
}