mirror of
https://github.com/Kozea/Radicale.git
synced 2025-08-04 18:22:26 +00:00
add support functions for retrieving path owner/group/permissions
This commit is contained in:
parent
348b123b43
commit
5582112029
1 changed files with 12 additions and 0 deletions
|
@ -23,6 +23,7 @@ Helper functions for working with the file system.
|
|||
|
||||
import errno
|
||||
import os
|
||||
import pathlib
|
||||
import posixpath
|
||||
import sys
|
||||
import threading
|
||||
|
@ -314,3 +315,14 @@ def name_from_path(path: str, collection: "storage.BaseCollection") -> str:
|
|||
raise ValueError("%r is not a component in collection %r" %
|
||||
(name, collection.path))
|
||||
return name
|
||||
|
||||
|
||||
def path_permissions(path):
|
||||
path = pathlib.Path(path)
|
||||
return [path.owner(), path.group(), path.stat().st_mode]
|
||||
|
||||
|
||||
def path_permissions_as_string(path):
|
||||
pp = path_permissions(path)
|
||||
s = "path=%r owner=%s group=%s mode=%o" % (path, pp[0], pp[1], pp[2])
|
||||
return s
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue