const.dart 3.0 KB

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