[helper] Filepath: Added accessibility helper method

Accessibility method helps identify whether a given save path directory is accessible for the user to write to.
This commit is contained in:
waaake 2024-12-23 09:01:56 +05:30
parent aeb77d8dbc
commit 9b96cfcc99

View file

@ -57,6 +57,13 @@ class FilepathHelper(QObject):
""" Returns the pathname without its extension (.ext)"""
return os.path.splitext(self.asStr(path))[0]
@Slot(str, result=bool)
@Slot(QUrl, result=bool)
def accessible(self, path):
""" Returns whether a path is accessible for the user """
path = self.asStr(path)
return os.path.isdir(self.asStr(path)) and os.access(path, os.R_OK) and os.access(path, os.W_OK)
@Slot(str, result=bool)
@Slot(QUrl, result=bool)
def isFile(self, path):