TomSecretsRuntime.current constructor

TomSecretsRuntime.current({
  1. Map<String, String>? environment,
  2. String? operatingSystem,
})

The runtime directory protocol.md 3.1 names for this process (or environment and operatingSystem); Unix sockets except on Windows.

Implementation

factory TomSecretsRuntime.current({
  Map<String, String>? environment,
  String? operatingSystem,
}) {
  final os = operatingSystem ?? Platform.operatingSystem;
  final location = discoverTomSecrets(
    operatingSystem: os,
    environment: environment ?? Platform.environment,
  );
  if (location is! TomSecretsEndpoints) {
    throw TomSecretsRuntimeException(
      'no runtime directory: neither LOCALAPPDATA nor USERPROFILE is set',
    );
  }
  return TomSecretsRuntime(
    location.directory,
    transport: os == 'windows'
        ? TomSecretsTransport.tcp
        : TomSecretsTransport.unix,
    // The paths of the OS asked for, not of the one this runs on.
    separator: os == 'windows' ? r'\' : '/',
  );
}