const.dart 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import 'dart:io';
  2. import 'package:path/path.dart' as path;
  3. import 'package:process_run/shell_run.dart';
  4. class ClashName {
  5. static String get platform {
  6. if (Platform.isWindows) return 'windows';
  7. if (Platform.isMacOS) return 'darwin';
  8. if (Platform.isLinux) return 'linux';
  9. return 'unknown';
  10. }
  11. static String get arch {
  12. return const String.fromEnvironment('OS_ARCH', defaultValue: 'amd64'); //amd64
  13. }
  14. static String get ext {
  15. if (Platform.isWindows) return '.exe';
  16. return '';
  17. }
  18. static String get name {
  19. return 'ccore-$platform-$arch$ext';
  20. }
  21. }
  22. class Paths {
  23. static Directory get assets {
  24. File mainFile = File(Platform.resolvedExecutable);
  25. String assetsPath = '../data/flutter_assets/assets';
  26. if (Platform.isMacOS) assetsPath = '../../Frameworks/App.framework/Resources/flutter_assets/assets';
  27. return Directory(path.normalize(path.join(mainFile.path, assetsPath)));
  28. }
  29. static Directory get assetsBin {
  30. return Directory(path.join(assets.path, 'bin'));
  31. }
  32. static Directory get assetsDep {
  33. return Directory(path.join(assets.path, 'dep'));
  34. }
  35. static Directory get config {
  36. return Directory(path.join(userHomePath, '.config', 'ccore'));
  37. }
  38. }
  39. class Files {
  40. static File get assetsClashCore {
  41. return File(path.join(Paths.assetsBin.path, ClashName.name));
  42. }
  43. static File get assetsClashService {
  44. return File(path.join(Paths.assetsBin.path, 'ccore-service-${ClashName.platform}-${ClashName.arch}${ClashName.ext}'));
  45. }
  46. static File get assetsCountryMmdb {
  47. return File(path.join(Paths.assetsDep.path, 'Country.mmdb'));
  48. }
  49. static File get assetsGeosite {
  50. return File(path.join(Paths.assetsDep.path, 'geosite.dat'));
  51. }
  52. static File get assetsGeoIP {
  53. return File(path.join(Paths.assetsDep.path, 'geoip.dat'));
  54. }
  55. static File get assetsWintun {
  56. return File(path.join(Paths.assetsDep.path, 'wintun.dll'));
  57. }
  58. static File get assetsExample {
  59. return File(path.join(Paths.assetsDep.path, 'example.yaml'));
  60. }
  61. static File get configConfig {
  62. return File(path.join(Paths.config.path, '.config.json'));
  63. }
  64. static File get makeProxyConfig {
  65. return File(path.join(Paths.config.path, 'proxy.yaml'));
  66. }
  67. static File get configCountryMmdb {
  68. return File(path.join(Paths.config.path, 'Country.mmdb'));
  69. }
  70. static File get configGeoIP {
  71. return File(path.join(Paths.config.path, 'geoip.dat'));
  72. }
  73. static File get configGeosite {
  74. return File(path.join(Paths.config.path, 'geosite.dat'));
  75. }
  76. static File get configWintun {
  77. return File(path.join(Paths.config.path, 'wintun.dll'));
  78. }
  79. static File get configExample {
  80. return File(path.join(Paths.config.path, 'example.yaml'));
  81. }
  82. }