src/eric7/SystemUtilities/FileSystemUtilities.py

branch
eric7
changeset 10396
2f72e9330af2
parent 10393
434e1b0bc49e
child 10397
f60464a5f7ea
diff -r 16933878e27b -r 2f72e9330af2 src/eric7/SystemUtilities/FileSystemUtilities.py
--- a/src/eric7/SystemUtilities/FileSystemUtilities.py	Thu Dec 07 10:40:51 2023 +0100
+++ b/src/eric7/SystemUtilities/FileSystemUtilities.py	Sun Dec 10 17:06:00 2023 +0100
@@ -729,6 +729,31 @@
     return mountedPaths
 
 
+def startfile(filePath):
+    """
+    Function to open the given file path with the system default application.
+
+    @param filePath file path to be opened
+    @type str or Path
+    @return flag indicating a successful start of the associated application
+    @rtype bool
+    """
+    filePath = str(filePath)
+
+    if OSUtilities.isWindowsPlatform():
+        return os.startfile(filePath)  # secok
+
+    elif OSUtilities.isMacPlatform():
+        return subprocess.call(("open", filePath))  # secok
+
+    elif OSUtilities.isLinuxPlatform() or OSUtilities.isFreeBsdPlatform():
+        return subprocess.call(("xdg-open", filePath))  # secok
+
+    else:
+        # unsupported platform
+        return False
+
+
 ################################################################################
 ## Functions below handle (MicroPython) device and remote file names.
 ################################################################################

eric ide

mercurial