W3cubDocs

/Dart 2

runZoned<R> method

R runZoned <R>(R body(), { Directory createDirectory(String), Directory getCurrentDirectory(), void setCurrentDirectory(String), Directory getSystemTempDirectory(), File createFile(String), Future<FileStat> stat(String), FileStat statSync(String), Future<bool> fseIdentical(String, String), bool fseIdenticalSync(String, String), Future<FileSystemEntityType> fseGetType(String, bool), FileSystemEntityType fseGetTypeSync(String, bool), Stream<FileSystemEvent> fsWatch(String, int, bool), bool fsWatchIsSupported(), Link createLink(String), Future<Socket> socketConnect(dynamic, int, { dynamic sourceAddress, Duration timeout }), Future<ConnectionTask<Socket>> socketStartConnect(dynamic, int, { dynamic sourceAddress }), ZoneSpecification zoneSpecification, Function onError })

Runs body in a fresh Zone using the provided overrides.

See the documentation on the corresponding methods of IOOverrides for information about what the optional arguments do.

Implementation

static R runZoned<R>(R body(),
    {
    // Directory
    Directory Function(String) createDirectory,
    Directory Function() getCurrentDirectory,
    void Function(String) setCurrentDirectory,
    Directory Function() getSystemTempDirectory,

    // File
    File Function(String) createFile,

    // FileStat
    Future<FileStat> Function(String) stat,
    FileStat Function(String) statSync,

    // FileSystemEntity
    Future<bool> Function(String, String) fseIdentical,
    bool Function(String, String) fseIdenticalSync,
    Future<FileSystemEntityType> Function(String, bool) fseGetType,
    FileSystemEntityType Function(String, bool) fseGetTypeSync,

    // _FileSystemWatcher
    Stream<FileSystemEvent> Function(String, int, bool) fsWatch,
    bool Function() fsWatchIsSupported,

    // Link
    Link Function(String) createLink,

    // Socket
    Future<Socket> Function(dynamic, int,
            {dynamic sourceAddress, Duration timeout})
        socketConnect,
    Future<ConnectionTask<Socket>> Function(dynamic, int,
            {dynamic sourceAddress})
        socketStartConnect,

    // Optional Zone parameters
    ZoneSpecification zoneSpecification,
    Function onError}) {
  IOOverrides overrides = new _IOOverridesScope(
    // Directory
    createDirectory,
    getCurrentDirectory,
    setCurrentDirectory,
    getSystemTempDirectory,

    // File
    createFile,

    // FileStat
    stat,
    statSync,

    // FileSystemEntity
    fseIdentical,
    fseIdenticalSync,
    fseGetType,
    fseGetTypeSync,

    // _FileSystemWatcher
    fsWatch,
    fsWatchIsSupported,

    // Link
    createLink,

    // Socket
    socketConnect,
    socketStartConnect,
  );
  return _asyncRunZoned<R>(body,
      zoneValues: {_ioOverridesToken: overrides},
      zoneSpecification: zoneSpecification,
      onError: onError);
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-io/IOOverrides/runZoned.html