38 lines
1.2 KiB
Dart
38 lines
1.2 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:path/path.dart' as p;
|
|
|
|
/// Stable per-user locations, independent of the installed bundle and cwd.
|
|
class AppPaths {
|
|
static String configuration({
|
|
Map<String, String>? environment,
|
|
bool? windows,
|
|
}) {
|
|
final env = environment ?? Platform.environment;
|
|
final isWindows = windows ?? Platform.isWindows;
|
|
final paths = p.Context(style: isWindows ? p.Style.windows : p.Style.posix);
|
|
final home = env['HOME'] ?? env['USERPROFILE'] ?? Directory.systemTemp.path;
|
|
return isWindows
|
|
? paths.join(env['LOCALAPPDATA'] ?? home, 'TTSTD', 'ADS-Flutter')
|
|
: paths.join(
|
|
env['XDG_CONFIG_HOME'] ?? paths.join(home, '.config'),
|
|
'ads-flutter',
|
|
);
|
|
}
|
|
|
|
static String logs({Map<String, String>? environment, bool? windows}) {
|
|
final env = environment ?? Platform.environment;
|
|
final isWindows = windows ?? Platform.isWindows;
|
|
if (isWindows) {
|
|
return p.Context(style: p.Style.windows)
|
|
.join(configuration(environment: env, windows: true), 'logs');
|
|
}
|
|
final home = env['HOME'] ?? Directory.systemTemp.path;
|
|
return p.posix.join(
|
|
env['XDG_STATE_HOME'] ?? p.posix.join(home, '.local', 'state'),
|
|
'ads-flutter',
|
|
'logs',
|
|
);
|
|
}
|
|
}
|