<commit_before>// Copyright (c) 2012, 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.

#library("builtin");

void print(arg) {
  _Logger._printString(arg.toString());
}

void exit(int status) {
  if (status is !int) {
    throw new IllegalArgumentException("int status expected");
  }
  _exit(status);
}

_exit(int status) native "Exit";

class _Logger {
  static void _printString(String s) native "Logger_PrintString";
}


// Code to deal with URI resolution for the standalone binary.
var _is_windows;

void _logResolution(String msg) {
  final enabled = false;
  if (enabled || _is_windows) {
    _Logger._printString(msg);
  }
}

// TODO(iposva): Make these private once the Dart API is fixed.
String resolveScriptUri(String cwd, String scriptName, bool windows) {
  _is_windows = windows;
  _logResolution("# Current working directory: $cwd");
  _logResolution("# ScriptName: $scriptName");
  if (windows) {
    // Convert
    // C:\one\two\three
    // to
    // /C:/one/two/three
    cwd = "/${cwd.replaceAll('\\', '/')}";
    _logResolution("## cwd: $cwd");
    if ((scriptName.length > 2) && (scriptName[1] == ":")) {
      // This is an absolute path.
      scriptName = "/${scriptName.replaceAll('\\', '/')}";
    } else {
      scriptName = scriptName.replaceAll('\\', '/');
    }
    _logResolution("## scriptName: $scriptName");
  }
  var base = new Uri(scheme: "file", path: cwd.endsWith("/") ? cwd : "$cwd/");
  var resolved = base.resolve(scriptName);
  _logResolution("# Resolved to: $resolved");
  return resolved.toString();
}

String resolveUri(String base, String userString) {
  var baseUri = new Uri.fromString(base);
  _logResolution("# Resolving: $userString from $base");
  var resolved = baseUri.resolve(userString);
  _logResolution("# Resolved to: $resolved");
  return resolved.toString(); 
}

String filePathFromUri(String userUri) {
  var uri = new Uri.fromString(userUri);
  _logResolution("# Getting file path from: $uri");
  if ("file" != uri.scheme) {
    // Only handling file URIs in standalone binary.
    _logResolution("# Not a file URI.");
    throw "Not a file uri: $uri";
  }
  _logResolution("# Path: ${uri.path}");
  return uri.path;
}<commit_msg>- Win: Remove leading / from file path.<commit_after>// Copyright (c) 2012, 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.

#library("builtin");

void print(arg) {
  _Logger._printString(arg.toString());
}

void exit(int status) {
  if (status is !int) {
    throw new IllegalArgumentException("int status expected");
  }
  _exit(status);
}

_exit(int status) native "Exit";

class _Logger {
  static void _printString(String s) native "Logger_PrintString";
}


// Code to deal with URI resolution for the standalone binary.
var _is_windows;

void _logResolution(String msg) {
  final enabled = false;
  if (enabled || _is_windows) {
    _Logger._printString(msg);
  }
}

// TODO(iposva): Make these private once the Dart API is fixed.
String resolveScriptUri(String cwd, String scriptName, bool windows) {
  _is_windows = windows;
  _logResolution("# Current working directory: $cwd");
  _logResolution("# ScriptName: $scriptName");
  if (windows) {
    // Convert
    // C:\one\two\three
    // to
    // /C:/one/two/three
    cwd = "/${cwd.replaceAll('\\', '/')}";
    _logResolution("## cwd: $cwd");
    if ((scriptName.length > 2) && (scriptName[1] == ":")) {
      // This is an absolute path.
      scriptName = "/${scriptName.replaceAll('\\', '/')}";
    } else {
      scriptName = scriptName.replaceAll('\\', '/');
    }
    _logResolution("## scriptName: $scriptName");
  }
  var base = new Uri(scheme: "file", path: cwd.endsWith("/") ? cwd : "$cwd/");
  var resolved = base.resolve(scriptName);
  _logResolution("# Resolved to: $resolved");
  return resolved.toString();
}

String resolveUri(String base, String userString) {
  var baseUri = new Uri.fromString(base);
  _logResolution("# Resolving: $userString from $base");
  var resolved = baseUri.resolve(userString);
  _logResolution("# Resolved to: $resolved");
  return resolved.toString(); 
}

String filePathFromUri(String userUri) {
  var uri = new Uri.fromString(userUri);
  _logResolution("# Getting file path from: $uri");
  if ("file" != uri.scheme) {
    // Only handling file URIs in standalone binary.
    _logResolution("# Not a file URI.");
    throw "Not a file uri: $uri";
  }
  var path = uri.path;
  _logResolution("# Path: $path");
  if (_is_windows) {
    // Drop the leading / before the drive letter.
    path = path.substring(1);
    _logResolution("# path: $path");
  }
  return path;
}
{'fraction_non_alphanumeric': 0.15096668037844507, 'fraction_numerical': 0.00267379679144385, 'mean_word_length': 3.6491395793499044, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5362049', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1534, 'n_words': 469}