<commit_before>

public class File: CustomStringConvertible {

  var _fd: Int32
  public let path: String

  // Lower level constructor. The validity of the fd parameter is not checked.
  public init(path: String, fd: Int32) {
    self.path = path
    self._fd = fd
  }

  public init(path: String, mode: FileOperation = .R) throws {
    self.path = path
    _fd = Sys.openFile(path, operation: mode)
    if _fd == -1 {
      throw FileError.Open
    }
  }

  public static let NEW_LINE = "\n"
  public static let WINDOWS_NEW_LINE = "\r\n"

/*  func puts(v: ) {
    var f = _f;
    if (v is List) {
      var i, len = v.length;
      for (i = 0; i < len; i++) {
        putStringEnsureNewLine(f, v[i]);
      }
    } else if (v is Iterable) {
      for (var e in v) {
        putStringEnsureNewLine(f, e);
      }
    } else {
      write(v is String ? v : v.toString());
    }
  }

  putStringEnsureNewLine(f, s) {
    if (s is! String) {
      s = s.toString();
    }
    Str.withNewLinePreference(s, IO.isWindows, (s, newLineStr) {
      write(s);
      if (newLineStr != null) {
        write(newLineStr);
      }
      });
  }*/

  public func print(v: String) {
    write(v)
  }

  public func read(maxBytes: Int = -1) throws -> String? {
    let a = try readCChar(maxBytes < 0 ? length : maxBytes)
    return String.fromCharCodes(a)
  }

  public func readBytes(maxBytes: Int = -1) throws -> [UInt8] {
    let len = maxBytes < 0 ? length : maxBytes
    var a = [UInt8](count: len, repeatedValue: 0)
    let n = try doRead(&a, maxBytes: len)
    if n < maxBytes {
      a = [UInt8](a[0..<n])
    }
    return a
  }

  public func readCChar(maxBytes: Int = -1) throws -> [CChar] {
    let len = maxBytes < 0 ? length : maxBytes
    var a = [CChar](count: len, repeatedValue: 0)
    let n = try doRead(&a, maxBytes: len)
    if n < maxBytes {
      a = [CChar](a[0..<n])
    }
    return a
  }
<commit_msg>Removed some commented out code from File.<commit_after>

public class File: CustomStringConvertible {

  var _fd: Int32
  public let path: String

  // Lower level constructor. The validity of the fd parameter is not checked.
  public init(path: String, fd: Int32) {
    self.path = path
    self._fd = fd
  }

  public init(path: String, mode: FileOperation = .R) throws {
    self.path = path
    _fd = Sys.openFile(path, operation: mode)
    if _fd == -1 {
      throw FileError.Open
    }
  }

  public func print(v: String) {
    write(v)
  }

  public func read(maxBytes: Int = -1) throws -> String? {
    let a = try readCChar(maxBytes < 0 ? length : maxBytes)
    return String.fromCharCodes(a)
  }

  public func readBytes(maxBytes: Int = -1) throws -> [UInt8] {
    let len = maxBytes < 0 ? length : maxBytes
    var a = [UInt8](count: len, repeatedValue: 0)
    let n = try doRead(&a, maxBytes: len)
    if n < maxBytes {
      a = [UInt8](a[0..<n])
    }
    return a
  }

  public func readCChar(maxBytes: Int = -1) throws -> [CChar] {
    let len = maxBytes < 0 ? length : maxBytes
    var a = [CChar](count: len, repeatedValue: 0)
    let n = try doRead(&a, maxBytes: len)
    if n < maxBytes {
      a = [CChar](a[0..<n])
    }
    return a
  }

{'fraction_non_alphanumeric': 0.13114754098360656, 'fraction_numerical': 0.011664564943253467, 'mean_word_length': 2.332983193277311, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 9, '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': '2711549', 'n_tokens_mistral': 1159, 'n_tokens_neox': 1128, 'n_words': 344}