Platforms to show: All Mac Windows Linux Cross-Platform

Back to ExtendedAttributesMBS module.

ExtendedAttributesMBS.Available as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacOSX Plugin 12.5 ✅ Yes ❌ No ✅ Yes ✅ Yes All
Returns true if extended attribute functions are available.

ExtendedAttributesMBS.GetAttribute(path as folderitem, name as string, options as Integer = 0) as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacOSX Plugin 12.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Get an extended attribute value.
Example
Var f As FolderItem = SpecialFolder.Desktop.Child("test.txt")
// query attribute
Var v As Variant = ExtendedAttributesMBS.GetAttribute(f, "com.apple.metadata:_kMDItemUserTags")

// plugin converts it to Xojo data types with variants
If v <> Nil Then
// tags should be an array of Variant with strings
Var a() As Variant = v

For Each s As String In a
MsgBox s
Next
End If

On Mac the extended attributes are normally formatted property lists, so please use the high level functions SetAttribute/GetAttribute. Raw functions are better for things like resourcefork or FinderInfo.

Extended attributes extend the basic attributes of files and directories in the file system. They are stored as name:data pairs associated with file system objects (files, directories, symlinks, etc).

The GetAttribute function retrieves all bytes of data from the extended attribute identified by name associated with path.

An extended attribute's name is a simple UTF-8 string. position specifies an offset within the extended attribute. In the current implementation, this argument is only used with the resource fork attribute. For all other extended attributes, this parameter is reserved and should be zero.

On success, returns the data associated with name.

Options specify options for retrieving extended attributes:
kNoFollowDo not follow symbolic links. getxattr() normally returns information from the target of path if it is a symbolic link. With this option, GetAttribute will return extended attribute data from the symbolic link instead.
kShowCompression: GetAttribute will return HFS Plus Compression extended attribute name (if present) for the file referred to by path or fd.

On success, the value is returned. On failure, nil is returned and lasterror is set.

See also:

ExtendedAttributesMBS.GetAttribute(path as string, name as string, options as Integer = 0) as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacOSX Plugin 12.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Get an extended attribute value.
Example
Var f as FolderItem = SpecialFolder.Desktop.Child("test.rtf")
Var v as Variant = ExtendedAttributesMBS.GetAttribute(f, ExtendedAttributesMBS.kAttributeNameFinderComment)
break // see comment string in debugger

On Mac the extended attributes are normally formatted property lists, so please use the high level functions SetAttribute/GetAttribute. Raw functions are better for things like resourcefork or FinderInfo.

Extended attributes extend the basic attributes of files and directories in the file system. They are stored as name:data pairs associated with file system objects (files, directories, symlinks, etc).

The GetAttribute function retrieves all bytes of data from the extended attribute identified by name associated with path.

An extended attribute's name is a simple UTF-8 string. position specifies an offset within the extended attribute. In the current implementation, this argument is only used with the resource fork attribute. For all other extended attributes, this parameter is reserved and should be zero.

On success, returns the data associated with name.

Options specify options for retrieving extended attributes:
kNoFollowDo not follow symbolic links. getxattr() normally returns information from the target of path if it is a symbolic link. With this option, GetAttribute will return extended attribute data from the symbolic link instead.
kShowCompression: GetAttribute will return HFS Plus Compression extended attribute name (if present) for the file referred to by path or fd.

On success, the value is returned. On failure, nil is returned and lasterror is set.

See also:

ExtendedAttributesMBS.GetRawAttribute(path as folderitem, name as string, options as Integer = 0) as memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacOSX Plugin 12.5 ✅ Yes ❌ No ✅ Yes ✅ Yes All
Get an extended attribute value.
Example
Var f as FolderItem = SpecialFolder.Desktop.Child("test.rtf")
Var value as MemoryBlock = ExtendedAttributesMBS.GetRawAttribute(f, ExtendedAttributesMBS.kAttributeNameFinderInfo)
break // see in debugger

On Mac the extended attributes are normally formatted property lists, so please use the high level functions SetAttribute/GetAttribute. Raw functions are better for things like resourcefork or FinderInfo.

Extended attributes extend the basic attributes of files and directories in the file system. They are stored as name:data pairs associated with file system objects (files, directories, symlinks, etc).

The GetRawAttribute function retrieves all bytes of data from the extended attribute identified by name associated with path.

An extended attribute's name is a simple UTF-8 string. position specifies an offset within the extended attribute. In the current implementation, this argument is only used with the resource fork attribute. For all other extended attributes, this parameter is reserved and should be zero.

On success, returns the data associated with name.

Options specify options for retrieving extended attributes:
kNoFollowDo not follow symbolic links. getxattr() normally returns information from the target of path if it is a symbolic link. With this option, GetRawAttribute will return extended attribute data from the symbolic link instead.
kShowCompression: GetRawAttribute will return HFS Plus Compression extended attribute name (if present) for the file referred to by path or fd.

On success, the value is returned. On failure, nil is returned and lasterror is set.

See also:

ExtendedAttributesMBS.GetRawAttribute(path as string, name as string, options as Integer = 0) as memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacOSX Plugin 12.5 ✅ Yes ❌ No ✅ Yes ✅ Yes All
Get an extended attribute value.

On Mac the extended attributes are normally formatted property lists, so please use the high level functions SetAttribute/GetAttribute. Raw functions are better for things like resourcefork or FinderInfo.

Extended attributes extend the basic attributes of files and directories in the file system. They are stored as name:data pairs associated with file system objects (files, directories, symlinks, etc).

The GetRawAttribute function retrieves all bytes of data from the extended attribute identified by name associated with path.

An extended attribute's name is a simple UTF-8 string. position specifies an offset within the extended attribute. In the current implementation, this argument is only used with the resource fork attribute. For all other extended attributes, this parameter is reserved and should be zero.

On success, returns the data associated with name.

Options specify options for retrieving extended attributes:
kNoFollowDo not follow symbolic links. getxattr() normally returns information from the target of path if it is a symbolic link. With this option, GetRawAttribute will return extended attribute data from the symbolic link instead.
kShowCompression: GetRawAttribute will return HFS Plus Compression extended attribute name (if present) for the file referred to by path or fd.

On success, the value is returned. On failure, nil is returned and lasterror is set.

See also:

ExtendedAttributesMBS.LastError as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacOSX Plugin 12.5 ✅ Yes ❌ No ✅ Yes ✅ Yes All
The last error code.

Possible error values:
EPERM1Attributes cannot be associated with this type of object. For example, attributes are not allowed for resource forks.
EIO5An I/O error occurred while reading from or writing to the file system.
E2BIG7The data size of the extended attribute is too large.
EACCES13Permissions denied
EFAULT14path or name points to an invalid address.
EEXIST17options contains XATTR_CREATE and the named attribute already exists.
ENOTDIR20A component of path's prefix is not a directory.
EISDIR21path or fd do not refer to a regular file and the attribute in question is only applicable to files. Similar to EPERM.
EINVAL22name or options is invalid. name must be valid UTF-8 and options must make sense.
ENOSPC28Not enough space left on the file system.
EROFS30The file system is mounted read-only.
ERANGE34The data size of the attribute is out of range (some attributes have size restrictions).
ENOTSUP45The file system does not support extended attributes or has the feature disabled.
ELOOP62Too many symbolic links were encountered resolving path.
ENAMETOOLONG63Name exceeded XATTR_MAXNAMELEN UTF-8 bytes, or a component of path exceeded NAME_MAX characters, or the entire path exceeded PATH_MAX characters.
ENOATTR93options is set to kReplace and the named attribute does not exist.

ExtendedAttributesMBS.LastErrorMessage as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacOSX Plugin 13.5 ✅ Yes ❌ No ✅ Yes ✅ Yes All
The error message for the last error.

ExtendedAttributesMBS.ListAttributes(path as folderitem, Options as Integer = 0) as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacOSX Plugin 12.5 ✅ Yes ❌ No ✅ Yes ✅ Yes All
List extended attribute names.
Example
Var f as FolderItem = SpecialFolder.Desktop.Child("test.rtf")
Var names() as string = ExtendedAttributesMBS.ListAttributes(f, ExtendedAttributesMBS.kNoFollow+ExtendedAttributesMBS.kShowCompression)
MsgBox Join(names, EndOfLine)

Extended attributes extend the basic attributes associated with files and directories in the file system. They are stored as name:data pairs associated with file system objects (files, directories, symlinks, etc).

ListAttributes retrieves a list of names of extended attributes associated with the given path in the file system. The list will only include names of extended attributes to which the calling process has access.

Options controls how the attribute list is generated:

kNoFollow: Do not follow symbolic links. ListAttributes normally lists attributes of the target of path if it is a symbolic link. With this option, ListAttributes will list attributes of the link itself.
kShowCompression: ListAttributes will list HFS Plus Compression extended attribute(s) (if present) for the file referred to by path.

On success returns array with names. If no accessible extended attributes are associated with the given path, the function returns empty array. Lasterror is set.

See also:

ExtendedAttributesMBS.ListAttributes(path as string, Options as Integer = 0) as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacOSX Plugin 12.5 ✅ Yes ❌ No ✅ Yes ✅ Yes All
List extended attribute names.

Extended attributes extend the basic attributes associated with files and directories in the file system. They are stored as name:data pairs associated with file system objects (files, directories, symlinks, etc).

ListAttributes retrieves a list of names of extended attributes associated with the given path in the file system. The list will only include names of extended attributes to which the calling process has access.

Options controls how the attribute list is generated:

kNoFollow: Do not follow symbolic links. ListAttributes normally lists attributes of the target of path if it is a symbolic link. With this option, ListAttributes will list attributes of the link itself.
kShowCompression: ListAttributes will list HFS Plus Compression extended attribute(s) (if present) for the file referred to by path.

On success returns array with names. If no accessible extended attributes are associated with the given path, the function returns empty array. Lasterror is set.

See also:

ExtendedAttributesMBS.RemoveAttribute(path as folderitem, name as string, options as Integer = 0) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacOSX Plugin 12.5 ✅ Yes ❌ No ✅ Yes ✅ Yes All
Remove an extended attribute value.

Extended attributes extend the basic attributes associated with files and directories in the file system. They are stored as name:data pairs associated with file system objects (files, directories, symlinks, etc).

RemoveAttribute deletes the extended attribute name associated with path.

An extended attribute's name is a simple UTF-8 string. Options is a bit mask specifying various options:

kNoFollowDo not follow symbolic links. Normally, removexattr() acts on the target of path if it is a symbolic link. With this option, RemoveAttribute will act on the link itself.
kShowCompression: RemoveAttribute will remove HFS Plus Compression extended attribute name (if present) for the file referred to by path or fd.

On success, true is returned. On failure, false is returned and the lasterror value is set.

See also:

ExtendedAttributesMBS.RemoveAttribute(path as string, name as string, options as Integer = 0) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacOSX Plugin 12.5 ✅ Yes ❌ No ✅ Yes ✅ Yes All
Remove an extended attribute value.

Extended attributes extend the basic attributes associated with files and directories in the file system. They are stored as name:data pairs associated with file system objects (files, directories, symlinks, etc).

RemoveAttribute deletes the extended attribute name associated with path.

An extended attribute's name is a simple UTF-8 string. Options is a bit mask specifying various options:

kNoFollowDo not follow symbolic links. Normally, removexattr() acts on the target of path if it is a symbolic link. With this option, RemoveAttribute will act on the link itself.
kShowCompression: RemoveAttribute will remove HFS Plus Compression extended attribute name (if present) for the file referred to by path or fd.

On success, true is returned. On failure, false is returned and the lasterror value is set.

See also:

ExtendedAttributesMBS.SetAttribute(path as folderitem, name as string, data as Variant, options as Integer = 0) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacOSX Plugin 12.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Set an extended attribute value.
Example
Var f as FolderItem = SpecialFolder.Desktop.Child("test.txt")
call ExtendedAttributesMBS.SetAttribute(f, ExtendedAttributesMBS.kAttributeNameFinderComment, "Test Comment")

On Mac the extended attributes are normally formatted property lists, so please use the high level functions SetAttribute/GetAttribute. Raw functions are better for things like resourcefork or FinderInfo.

Extended attributes extend the basic attributes associated with files and directories in the file system. They are stored as name:data pairs associated with file system objects (files, directories, symlinks, etc).

SetAttribute associates name and data together as an attribute of path.

An extended attribute's name is a simple UTF-8 string. Data is a memoryblock with the data and contains textual or binary data to be associated with the extended attribute. Position specifies the offset within the extended attribute. In the current implementation, only the resource fork extended attribute makes use of this argument. For all others, position is reserved and should be set to zero.

Options controls how the attribute is set:
kNoFollowDo not follow symbolic links. SetAttribute normally sets attributes on the target of path if it is a symbolic link. With this option, SetAttribute will act on the link itself.
kCreateFail if the named attribute already exists.
kReplaceFail if the named attribute does not exist. Failure to specify kReplace or kCreate allows creation and replacement.

On some filesystems, such as HFS+, setting the extended attribute com.apple.ResourceFork will update the modification time of the file.

Returns true on success and false on failure. Lasterror is set.
You may need to inform other applications like Finder that file changed and attributes need to be read.

See also:

ExtendedAttributesMBS.SetAttribute(path as string, name as string, data as Variant, options as Integer = 0) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacOSX Plugin 12.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Set an extended attribute value.

On Mac the extended attributes are normally formatted property lists, so please use the high level functions SetAttribute/GetAttribute. Raw functions are better for things like resourcefork or FinderInfo.

Extended attributes extend the basic attributes associated with files and directories in the file system. They are stored as name:data pairs associated with file system objects (files, directories, symlinks, etc).

SetAttribute associates name and data together as an attribute of path.

An extended attribute's name is a simple UTF-8 string. Data is a memoryblock with the data and contains textual or binary data to be associated with the extended attribute. Position specifies the offset within the extended attribute. In the current implementation, only the resource fork extended attribute makes use of this argument. For all others, position is reserved and should be set to zero.

Options controls how the attribute is set:
kNoFollowDo not follow symbolic links. SetAttribute normally sets attributes on the target of path if it is a symbolic link. With this option, SetAttribute will act on the link itself.
kCreateFail if the named attribute already exists.
kReplaceFail if the named attribute does not exist. Failure to specify kReplace or kCreate allows creation and replacement.

On some filesystems, such as HFS+, setting the extended attribute com.apple.ResourceFork will update the modification time of the file.

Returns true on success and false on failure. Lasterror is set.
You may need to inform other applications like Finder that file changed and attributes need to be read.

See also:

ExtendedAttributesMBS.SetRawAttribute(path as folderitem, name as string, data as memoryblock, options as Integer = 0) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacOSX Plugin 12.5 ✅ Yes ❌ No ✅ Yes ✅ Yes All
Set an extended attribute value.

On Mac the extended attributes are normally formatted property lists, so please use the high level functions SetAttribute/GetAttribute. Raw functions are better for things like resourcefork or FinderInfo.

Extended attributes extend the basic attributes associated with files and directories in the file system. They are stored as name:data pairs associated with file system objects (files, directories, symlinks, etc).

SetRawAttribute associates name and data together as an attribute of path.

An extended attribute's name is a simple UTF-8 string. Data is a memoryblock with the data and contains textual or binary data to be associated with the extended attribute. Position specifies the offset within the extended attribute. In the current implementation, only the resource fork extended attribute makes use of this argument. For all others, position is reserved and should be set to zero.

Options controls how the attribute is set:
kNoFollowDo not follow symbolic links. SetRawAttribute normally sets attributes on the target of path if it is a symbolic link. With this option, SetRawAttribute will act on the link itself.
kCreateFail if the named attribute already exists.
kReplaceFail if the named attribute does not exist. Failure to specify kReplace or kCreate allows creation and replacement.

On some filesystems, such as HFS+, setting the extended attribute com.apple.ResourceFork will update the modification time of the file.

Returns true on success and false on failure. Lasterror is set.
You may need to inform other applications like Finder that file changed and attributes need to be read.

See also:

ExtendedAttributesMBS.SetRawAttribute(path as string, name as string, data as memoryblock, options as Integer = 0) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS MacOSX Plugin 12.5 ✅ Yes ❌ No ✅ Yes ✅ Yes All
Set an extended attribute value.

On Mac the extended attributes are normally formatted property lists, so please use the high level functions SetAttribute/GetAttribute. Raw functions are better for things like resourcefork or FinderInfo.

Extended attributes extend the basic attributes associated with files and directories in the file system. They are stored as name:data pairs associated with file system objects (files, directories, symlinks, etc).

SetRawAttribute associates name and data together as an attribute of path.

An extended attribute's name is a simple UTF-8 string. Data is a memoryblock with the data and contains textual or binary data to be associated with the extended attribute. Position specifies the offset within the extended attribute. In the current implementation, only the resource fork extended attribute makes use of this argument. For all others, position is reserved and should be set to zero.

Options controls how the attribute is set:
kNoFollowDo not follow symbolic links. SetRawAttribute normally sets attributes on the target of path if it is a symbolic link. With this option, SetRawAttribute will act on the link itself.
kCreateFail if the named attribute already exists.
kReplaceFail if the named attribute does not exist. Failure to specify kReplace or kCreate allows creation and replacement.

On some filesystems, such as HFS+, setting the extended attribute com.apple.ResourceFork will update the modification time of the file.

Returns true on success and false on failure. Lasterror is set.
You may need to inform other applications like Finder that file changed and attributes need to be read.

See also:

The items on this page are in the following plugins: MBS MacOSX Plugin.


The biggest plugin in space...