1010
1111import 'dart:io' ;
1212
13+ import 'package:path/path.dart' as path;
1314import 'package:path_provider/path_provider.dart' ;
1415import 'package:permission_handler/permission_handler.dart' ;
1516
@@ -40,14 +41,17 @@ abstract class StackFileSystem {
4041 if (Util .isArmLinux) {
4142 appDirectory = await getApplicationDocumentsDirectory ();
4243 appDirectory = Directory (
43- "${ appDirectory .path }/ .${AppConfig .appDefaultDataDirName }" ,
44+ path. join ( appDirectory.path, " .${AppConfig .appDefaultDataDirName }") ,
4445 );
4546 } else if (Platform .isLinux) {
4647 if (_overrideDesktopDirPath != null ) {
4748 appDirectory = Directory (_overrideDesktopDirPath! );
4849 } else {
4950 appDirectory = Directory (
50- "${Platform .environment ['HOME' ]}/.${AppConfig .appDefaultDataDirName }" ,
51+ path.join (
52+ Platform .environment['HOME' ]! ,
53+ ".${AppConfig .appDefaultDataDirName }" ,
54+ ),
5155 );
5256 }
5357 } else if (Platform .isWindows) {
@@ -62,7 +66,7 @@ abstract class StackFileSystem {
6266 } else {
6367 appDirectory = await getLibraryDirectory ();
6468 appDirectory = Directory (
65- "${ appDirectory .path }/${ AppConfig .appDefaultDataDirName }" ,
69+ path. join ( appDirectory.path, AppConfig .appDefaultDataDirName) ,
6670 );
6771 }
6872 } else if (Platform .isIOS) {
@@ -86,7 +90,7 @@ abstract class StackFileSystem {
8690 static Future <Directory > applicationIsarDirectory () async {
8791 final root = await applicationRootDirectory ();
8892 if (_createSubDirs) {
89- final dir = Directory ("${ root .path }/ isar" );
93+ final dir = Directory (path. join ( root.path, " isar") );
9094 if (! dir.existsSync ()) {
9195 await dir.create ();
9296 }
@@ -99,7 +103,7 @@ abstract class StackFileSystem {
99103 static Future <Directory > applicationDriftDirectory () async {
100104 final root = await applicationRootDirectory ();
101105 if (_createSubDirs) {
102- final dir = Directory ("${ root .path }/ drift" );
106+ final dir = Directory (path. join ( root.path, " drift") );
103107 if (! dir.existsSync ()) {
104108 await dir.create ();
105109 }
@@ -126,7 +130,7 @@ abstract class StackFileSystem {
126130 static Future <Directory > applicationTorDirectory () async {
127131 final root = await applicationRootDirectory ();
128132 if (_createSubDirs) {
129- final dir = Directory ("${ root .path }/ tor" );
133+ final dir = Directory (path. join ( root.path, " tor") );
130134 if (! dir.existsSync ()) {
131135 await dir.create ();
132136 }
@@ -139,7 +143,7 @@ abstract class StackFileSystem {
139143 static Future <Directory > applicationFiroCacheSQLiteDirectory () async {
140144 final root = await applicationRootDirectory ();
141145 if (_createSubDirs) {
142- final dir = Directory ("${ root .path }/ sqlite/ firo_cache" );
146+ final dir = Directory (path. join ( root.path, " sqlite" , " firo_cache") );
143147 if (! dir.existsSync ()) {
144148 await dir.create (recursive: true );
145149 }
@@ -152,7 +156,7 @@ abstract class StackFileSystem {
152156 static Future <Directory > applicationHiveDirectory () async {
153157 final root = await applicationRootDirectory ();
154158 if (_createSubDirs) {
155- final dir = Directory ("${ root .path }/ hive" );
159+ final dir = Directory (path. join ( root.path, " hive") );
156160 if (! dir.existsSync ()) {
157161 await dir.create ();
158162 }
@@ -164,7 +168,7 @@ abstract class StackFileSystem {
164168
165169 static Future <Directory > applicationXelisDirectory () async {
166170 final root = await applicationRootDirectory ();
167- final dir = Directory ("${ root .path }${ Platform . pathSeparator } xelis" );
171+ final dir = Directory (path. join ( root.path, " xelis") );
168172 if (! dir.existsSync ()) {
169173 await dir.create ();
170174 }
@@ -173,7 +177,7 @@ abstract class StackFileSystem {
173177
174178 static Future <Directory > applicationXelisTableDirectory () async {
175179 final xelis = await applicationXelisDirectory ();
176- final dir = Directory ("${ xelis .path }${ Platform . pathSeparator } table" );
180+ final dir = Directory (path. join ( xelis.path, " table") );
177181 if (! dir.existsSync ()) {
178182 await dir.create ();
179183 }
@@ -183,7 +187,7 @@ abstract class StackFileSystem {
183187 static Future <void > initThemesDir () async {
184188 final root = await applicationRootDirectory ();
185189
186- final dir = Directory ("${ root .path }/ themes" );
190+ final dir = Directory (path. join ( root.path, " themes") );
187191 if (! dir.existsSync ()) {
188192 await dir.create ();
189193 }
@@ -206,13 +210,18 @@ abstract class StackFileSystem {
206210 final Directory logsDir;
207211
208212 if (Platform .isIOS) {
209- logsDir = Directory ("${ appDocsDir .path }/ logs" );
213+ logsDir = Directory (path. join ( appDocsDir.path, " logs") );
210214 } else if (Platform .isMacOS || Platform .isLinux || Platform .isWindows) {
211215 // TODO check this is correct for macos
212- logsDir = Directory ("${ appDocsDir .path }/$ logsDirName " );
216+ logsDir = Directory (path. join ( appDocsDir.path, logsDirName) );
213217 } else if (Platform .isAndroid) {
214218 await Permission .storage.request ();
215- logsDir = Directory ("/storage/emulated/0/Documents/$logsDirName " );
219+ final ext = await getExternalStorageDirectory ();
220+ final rootPath = path.dirname (
221+ path.dirname (path.dirname (path.dirname (ext! .path))),
222+ );
223+ final logsDirPath = path.join (rootPath, "Documents" , logsDirName);
224+ logsDir = Directory (logsDirPath);
216225 } else {
217226 throw Exception ("Unsupported Platform" );
218227 }
0 commit comments