A bunch of changes
This commit is contained in:
@@ -155,3 +155,33 @@ class XattrManager:
|
||||
except Exception as e:
|
||||
raise IOError(f"Could not save xattr '{attr_name}' "
|
||||
"for {file_path}: {e}") from e
|
||||
|
||||
@staticmethod
|
||||
def get_all_attributes(path):
|
||||
"""
|
||||
Gets all extended attributes for a file as a dictionary.
|
||||
|
||||
Args:
|
||||
path (str): The path to the file.
|
||||
|
||||
Returns:
|
||||
dict: A dictionary mapping attribute names to values.
|
||||
"""
|
||||
attributes = {}
|
||||
if not path:
|
||||
return attributes
|
||||
try:
|
||||
keys = os.listxattr(path)
|
||||
for key in keys:
|
||||
try:
|
||||
val = os.getxattr(path, key)
|
||||
try:
|
||||
val_str = val.decode('utf-8')
|
||||
except UnicodeDecodeError:
|
||||
val_str = str(val)
|
||||
attributes[key] = val_str
|
||||
except (OSError, AttributeError):
|
||||
pass
|
||||
except (OSError, AttributeError):
|
||||
pass
|
||||
return attributes
|
||||
|
||||
Reference in New Issue
Block a user