Platforms to show: All Mac Windows Linux Cross-Platform

Back to MacAliasMBS class.

MacAliasMBS.AliasInfo as AliasInfoMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Alias MBS MacClassic Plugin 13.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Queries alias info for the alias.
Example
dim m as new MacAliasMBS
dim f as FolderItem = SpecialFolder.Desktop

if m.Create(nil, f) = 0 then
dim info as AliasInfoMBS = m.AliasInfo

MsgBox info.TargetName + EndOfLine + info.VolumeName + EndOfLine + info.PathString
end if

Some examples using this method:

MacAliasMBS.close

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Alias MBS MacClassic Plugin 3.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The destructor.

There is no need to call this method except you want to free all resources of this object now without waiting for Xojo to do it for you.

MacAliasMBS.Create(relPath as FolderItem, target as FolderItem, isDirectory as boolean = false) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Alias MBS MacClassic Plugin ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Creates an AliasRecord for a given file or folder.
Example
dim m as new MacAliasMBS

dim e as Integer = m.Create(nil, SpecialFolder.Desktop.Child("test.txt"), true)

// shows -43 as we created alias for non existing file
MsgBox str(e)
MsgBox m.AliasInfo.TargetName

Returns zero if successful, otherwise a negative Mac OS error code.

Version 16.0 can create alias for non existing files. In that case you can tell with function isDirectory whether the target should be a directory. Still returns fnfErr (-43) if file doesn't exist but the alias will still be created.

MacAliasMBS.CreateAliasFromPath(targetPath as string, fromFilePath as String = "", isDirectory as boolean = false) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Alias MBS MacClassic Plugin 16.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Creates an alias given a POSIX style utf-8 path to the target.
Example
dim m as new MacAliasMBS

dim e as Integer = m.CreateAliasFromPath("/Users/test", "", true)

// shows -43 as we created alias for non existing file
MsgBox str(e)
MsgBox m.AliasInfo.TargetName

Returns OS error code.

If the target file does not exist but the path up to the leaf does then fnfErr (-43) will be returned but the alias will still be created.

fromFilePath: The starting point for a relative search.
targetPath: POSIX style UTF-8 path to target.
IsDirectory: On input, if target does not exist, a flag to indicate whether or not the target is a directory.

MacAliasMBS.CreateFSRef(relPath as memoryblock, target as memoryblock) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Alias MBS MacClassic Plugin ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Creates an AliasRecord for a given file or folder.

The two memoryblocks are FSRefs which you can get by FolderItem.FSRef.
Returns zero if successful, otherwise a negative Mac OS error code.

MacAliasMBS.CreateMinimal(target as FolderItem, isDirectory as boolean = false) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Alias MBS MacClassic Plugin ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Creates an AliasRecord for a given file or folder. Returns zero if successful, otherwise a negative Mac OS error code.

Minimal creates an alias without path, so it is smaller.

Version 16.0 can create alias for non existing files. In that case you can tell with function isDirectory whether the target should be a directory. Still returns fnfErr (-43) if file doesn't exist but the alias will still be created.

MacAliasMBS.CreateMinimalFSRef(target as memoryblock) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Alias MBS MacClassic Plugin ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Creates a minimal AliasRecord for a given file or folder.

The memoryblock is a FSRefs which you can get by FolderItem.FSRef.
Returns zero if successful, otherwise a negative Mac OS error code.

MacAliasMBS.GetRecord as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Alias MBS MacClassic Plugin ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the AliasRecord in a String so that you can store it in a file, and pass it SetRecord for re-creating the AliasRecord (this string might contain any byte values, including zeros, so you can not display it or store it in a text file - you have to store it in a binary file or in a resource, instead!).

Attention: The length of the String is not fixed! When the Alias changes, its length usually changes, too. If you want to save this string into a binary file, you must also save its current length so that you know how much bytes to retrieve if you read it back from the file later. An easier way to store Aliases in a file is by using the Resource Manager. The sample code "FolderItems in Preferences.rbp" shows how to accomplish this.

MacAliasMBS.PathString as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Alias MBS MacClassic Plugin 13.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Queries path of the alias.
Example
dim m as new MacAliasMBS
dim f as FolderItem = SpecialFolder.Desktop

if m.Create(nil, f) = 0 then
MsgBox m.PathString
end if

MacAliasMBS.Resolve(relPath as FolderItem, mode as Integer) as FolderItem

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Alias MBS MacClassic Plugin ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Converts an AliasRecord back into a FolderItem. For values to the mode parameter see the class constants or pass in 0 for default searching (will not attempt to mount unavailable volumes).

After calling this method, the property needsUpdate tells you whether the target has been renamed or moved, which suggests that you call Update in order to reflect the change in the AliasRecord. See the demo "FolderItems in Preferences.rbp" for an example.

MacAliasMBS.SetRecord(record as String)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Alias MBS MacClassic Plugin ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Use this method to revive an AliasRecord with the string you inquired from GetRecord earlier.

Some examples using this method:

MacAliasMBS.TargetName as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Alias MBS MacClassic Plugin 13.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Queries target name of the alias.
Example
dim m as new MacAliasMBS
dim f as FolderItem = SpecialFolder.Desktop

if m.Create(nil, f) = 0 then
MsgBox m.TargetName
end if

MacAliasMBS.Update(relPath as FolderItem, target as FolderItem) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Alias MBS MacClassic Plugin ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Updates an already created AliasRecord. Returns either a negative Mac OS error code, zero if the update didn't actually change the AliasRecord, or one if the record was changed (in this case you might want to update your record of the alias if you had stored it in a file).

MacAliasMBS.VolumeName as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Alias MBS MacClassic Plugin 13.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Queries volume name of the alias.
Example
dim m as new MacAliasMBS
dim f as FolderItem = SpecialFolder.Desktop

if m.Create(nil, f) = 0 then
MsgBox m.VolumeName
end if

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


The biggest plugin in space...