openFile static method
- FileEntry file, {
- dynamic folder = false,
Fonction ouvrant le fichier associé dans l'application préférée par l'utilistaeur
Implementation
static Future<void> openFile(FileEntry file, {folder=false}) async {
if (!Platform.isWindows){
if (folder){
await Process.run("open", ["${BASEDIR}${file.courseID}/${file.parent}/${file.name}"]);
}
else{
await Process.run("open", ["${BASEDIR}${file.courseID}/${file.name}"]);
}
}
else{
// IF ON WINDOWS open the file this way (because for some reason start is a better command to open files than open.)
// a function which was 5 lines long became a function 25 lines long....
if (folder){
await Process.start(
'cmd',
['/c', 'start', '', "$WIN_BASEDIR${file.courseID}\\${file.parent}\\${file.name}"],
runInShell: true,
);
}
else{
await Process.start(
'cmd',
['/c', 'start', '', "$WIN_BASEDIR${file.courseID}\\${file.name}"],
runInShell: true,
);
}
}
}