Platforms to show: All Mac Windows Linux Cross-Platform

Back to WindowsJunctionMBS module.

WindowsJunctionMBS.CreateHardLink(NewFile as folderitem, TargetFile as folderitem) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS Win Plugin 11.3 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Establishes a hard link between an existing file and a new file.
Example
dim file as FolderItem = SpecialFolder.Desktop.Child("test.exe")
dim nfile as FolderItem = SpecialFolder.Desktop.Child("hello.exe")

if WindowsJunctionMBS.CreateHardLink(nfile, file) then
MsgBox "OK"
end if

This function is only supported on the NTFS file system, and only for files, not directories.

NewFile: The name of the new file. Function fails if NewFile exists already. This parameter cannot specify the name of a directory.
TargetFile: The name of the existing file. This parameter cannot specify the name of a directory.

Returns true on success. Lasterror is set.

The maximum number of hard links that can be created with this function is 1023 per file. If more than 1023 links are created for a file, an error results.

Any directory entry for a file that is created with CreateFile or CreateHardLink is a hard link to an associated file. An additional hard link that is created with the CreateHardLink function allows you to have multiple directory entries for a file, that is, multiple hard links to the same file, which can be different names in the same directory, or the same or different names in different directories. However, all hard links to a file must be on the same volume.
Because hard links are only directory entries for a file, many changes to that file are instantly visible to applications that access it through the hard links that reference it. However, the directory entry size and attribute information is updated only for the link through which the change was made.
The security descriptor belongs to the file to which a hard link points. The link itself is only a directory entry, and does not have a security descriptor. Therefore, when you change the security descriptor of a hard link, you a change the security descriptor of the underlying file, and all hard links that point to the file allow the newly specified access. You cannot give a file different security descriptors on a per-hard-link basis.

Use DeleteFile to delete hard links (folderitem.delete in Xojo). You can delete them in any order regardless of the order in which they are created.
Flags, attributes, access, and sharing that are specified in CreateFile operate on a per-file basis. That is, if you open a file that does not allow sharing, another application cannot share the file by creating a new hard link to the file.
When you create a hard link on the NTFS file system, the file attribute information in the directory entry is refreshed only when the file is opened, or when GetFileInformationByHandle is called with the handle of a specific file.
Symbolic link behavior—If the path points to a symbolic link, the function creates a hard link to the target.

Lasterror is set. Returns true on success.

WindowsJunctionMBS.CreateJunction(JunctionDir as folderitem, TargetDir as folderitem) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS Win Plugin 11.3 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Creates a new junction.
Example
dim file as FolderItem = SpecialFolder.Desktop.Child("test")
dim nfile as FolderItem = SpecialFolder.System

if WindowsJunctionMBS.CreateJunction(file, nfile) then
MsgBox "OK"
end if

Lasterror is set. Returns true on success.

WindowsJunctionMBS.CreateSymbolicLink(NewFile as folderitem, TargetFile as folderitem) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS Win Plugin 11.3 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Creates a symbolic link.
Example
dim file as FolderItem = SpecialFolder.Desktop.Child("test.lnk")
dim nfile as FolderItem = SpecialFolder.Desktop.Child("test.txt")

if WindowsJunctionMBS.CreateSymbolicLink(file,nfile) then
MsgBox "Ok"
end if

NewFile: The symbolic link to be created.
TargetFile: The name of the target for the symbolic link to be created. If TargetFile has a device name associated with it, the link is treated as an absolute link; otherwise, the link is treated as a relative link.
TargetIsDirectory: Indicates whether the link target, TargetFile, is a directory. (Pass true for a directory).

Returns true on success. False on failure. Lasterror is set.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Symbolic links can either be absolute or relative links. Absolute links are links that specify each portion of the path name; relative links are determined relative to where relative–link specifiers are in a specified path. Relative links are specified using the following conventions:

  • Dot (. and ..) conventions—for example, "..\" resolves the path relative to the parent directory.
  • Names with no slashes (\)—for example, "tmp" resolves the path relative to the current directory.
  • Root relative—for example, "\Windows\System32" resolves to "current drive:\Windows\System32".
  • Current working directory–relative—for example, if the current working directory is C:\Windows\System32, "C:File.txt" resolves to "C:\Windows\System32\File.txt".

If you specify a current working directory–relative link, it is created as an absolute link, due to the way the current working directory is processed based on the user and the thread.

This function can fail due to missing permissions.

See also:

WindowsJunctionMBS.CreateSymbolicLink(NewFile as folderitem, TargetFile as string, TargetIsDirectory as Boolean) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS Win Plugin 11.3 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Creates a symbolic link.

NewFile: The symbolic link to be created.
TargetFile: The name of the target for the symbolic link to be created. If TargetFile has a device name associated with it, the link is treated as an absolute link; otherwise, the link is treated as a relative link.
TargetIsDirectory: Indicates whether the link target, TargetFile, is a directory. (Pass true for a directory).

Returns true on success. False on failure. Lasterror is set.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Symbolic links can either be absolute or relative links. Absolute links are links that specify each portion of the path name; relative links are determined relative to where relative–link specifiers are in a specified path. Relative links are specified using the following conventions:

  • Dot (. and ..) conventions—for example, "..\" resolves the path relative to the parent directory.
  • Names with no slashes (\)—for example, "tmp" resolves the path relative to the current directory.
  • Root relative—for example, "\Windows\System32" resolves to "current drive:\Windows\System32".
  • Current working directory–relative—for example, if the current working directory is C:\Windows\System32, "C:File.txt" resolves to "C:\Windows\System32\File.txt".

If you specify a current working directory–relative link, it is created as an absolute link, due to the way the current working directory is processed based on the user and the thread.

This function can fail due to missing permissions.

See also:

WindowsJunctionMBS.DeleteJunction(JunctionDir as folderitem) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS Win Plugin 11.3 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Deletes the junction.
Example
dim file as FolderItem = SpecialFolder.Desktop.Child("test")

if WindowsJunctionMBS.DeleteJunction(file) then
MsgBox "Ok"
end if

Folder is not deleted.

WindowsJunctionMBS.GetJunctionTarget(JunctionDir as folderitem) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS Win Plugin 11.3 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Checks whether a directory is a directory junction.
Example
dim file as FolderItem = SpecialFolder.Desktop.Child("test")

msgbox WindowsJunctionMBS.GetJunctionTarget(file)

Lasterror is set. Returns path of junction target.

WindowsJunctionMBS.HardLinksForFile(path as string) as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS Win Plugin 19.1 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Finds all the hard links to the specified file.
Example
dim path as string = "C:\Users\Christian\Desktop\test.xojo_binary_project"

dim oldfile as FolderItem = GetFolderItem(path, FolderItem.PathTypeNative)
dim newfile as FolderItem = GetFolderItem(path+".copy", FolderItem.PathTypeNative)

call WindowsJunctionMBS.CreateHardLink(newfile, oldfile)

dim paths() as string = WindowsJunctionMBS.HardLinksForFile(path)

MsgBox Join(paths, EndOfLine)

Path: The name of the file.

Array has only one entry if file has no other hard links.

WindowsJunctionMBS.IsDirectoryJunction(JunctionDir as folderitem) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS Win Plugin 11.3 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Checks whether a directory is a directory junction.
Example
dim file as FolderItem = SpecialFolder.Desktop.Child("test")

if WindowsJunctionMBS.IsDirectoryJunction(file) then
MsgBox "Is junction."
else
MsgBox "Is no junction."
end if

Returns true if this file is a junction.
Lasterror is set.

WindowsJunctionMBS.Lasterror as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Files MBS Win Plugin 11.3 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Returns the last error code.

Value is 0 for no error
-1 for some parameter error or not implemented inside plugin.
other values are windows error codes.

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


The biggest plugin in space...