@@ -17,8 +17,30 @@ class CCExtractor {
1717
1818 SettingsRepository settingsRepository = SettingsRepository ();
1919 SettingsModel settings = SettingsModel ();
20+
21+ /// Get the CCExtractor executable path.
22+ /// First checks for a bundled executable next to the app, then falls back
23+ /// to the system PATH.
2024 String get ccextractor {
21- return Platform .isWindows ? './ccextractorwinfull.exe' : './ccextractor' ;
25+ final executableName =
26+ Platform .isWindows ? 'ccextractorwinfull.exe' : 'ccextractor' ;
27+
28+ // Try relative to the running executable (for packaged/bundled apps)
29+ final execDir = File (Platform .resolvedExecutable).parent.path;
30+ final execPath = '$execDir /$executableName ' ;
31+ final execFile = File (execPath);
32+ if (execFile.existsSync ()) {
33+ // Verify it's actually a file (not a directory) and exists
34+ final stat = execFile.statSync ();
35+ if (stat.type == FileSystemEntityType .file) {
36+ logger.d ('Found bundled CCExtractor at: $execPath ' );
37+ return execPath;
38+ }
39+ }
40+
41+ // Fall back to system PATH (most common case for installed ccextractor)
42+ logger.d ('Using CCExtractor from system PATH: $executableName ' );
43+ return executableName;
2244 }
2345
2446 Future <int > extractFile (
@@ -30,24 +52,31 @@ class CCExtractor {
3052 settings = await settingsRepository.getSettings ();
3153 List <String > paramsList =
3254 settingsRepository.getParamsList (settings, filePath: file.path);
33- process = await Process .start (
34- ccextractor,
35- [
36- file.path,
37- '--gui-mode-reports' ,
38- ...paramsList,
39- ],
40- );
55+
56+ final args = [
57+ file.path,
58+ '--gui-mode-reports' ,
59+ ...paramsList,
60+ ];
61+ logger.i ('Starting CCExtractor: $ccextractor ' );
62+ logger.d ('Arguments: $args ' );
63+
64+ try {
65+ process = await Process .start (ccextractor, args);
66+ } catch (e, stackTrace) {
67+ logger.e ('Failed to start CCExtractor process' , error: e, stackTrace: stackTrace);
68+ rethrow ;
69+ }
4170 // sometimes stdout and stderr have important logs like how much time
4271 // it took to process the file or some erros not captured by exitcodes,
4372 // so just print them to the logs box
4473 process.stdout.transform (latin1.decoder).listen ((update) {
45- // print( update);
74+ logger. d ( 'CCExtractor stdout: $ update ' );
4675 listenOutput (update);
4776 });
4877
4978 process.stderr.transform (latin1.decoder).listen ((update) {
50- // print( update);
79+ logger. d ( 'CCExtractor stderr: $ update ' );
5180 if (progressRegx.hasMatch (update)) {
5281 for (RegExpMatch i in progressRegx.allMatches (update)) {
5382 listenProgress (i[1 ]! );
0 commit comments