Reparse Points and Shortcut Remapping Rules
Junctions and Directory Symbolic Links are filesystem links implemented using Windows reparse points. A Windows Shortcut (.lnk) is different. It is a Shell Link file and is not a reparse point. Although these objects are implemented differently, Windows Explorer can allow all three to provide access to another folder. A Junction or Directory Symbolic Link is resolved by the filesystem when its path is accessed, while a .lnk Shortcut is resolved by the Windows Shell.
This section describes how CrazyCopy treats different file types with respect to the paths held inside their metadata. The following file types contain a link or reference to a file or folder, known as the target. Windows shortcuts also contain a Working Directory in the metadata. Paths in these file objects can be either relative or absolute. Different rules apply to each type.
- Junction (mklink /J)
- Target Folder (Absolute or Relative path)
- Hardlink (mklink /H)
- No Target Pathname
- File Symbolic Link (mklink)
- Target (Absolute or Relative path)
- Directory Symbolic Link (mklink /D)
- Target (Absolute or Relative path)
- Shortcut (.lnk)
- Target (Absolute path only)
- Working Directory (Absolute or Relative path)
The table below shows the exact behaviour of CrazyCopy when it encounters different file types.
Definitions of Terms
Reparse Point : A special Windows filesystem object containing metadata that causes the filesystem to handle a path differently from a normal file or folder. Junctions and Directory Symbolic Links are types of reparse points and can redirect access to another folder.
Internal Target : A file or folder within the tree being copied or moved, that is referenced by another filesystem object
Internal Directory : A folder being moved or copied as part of the operation that is referenced by another file (link/junction/shortcut)
External : The file or folder is outside the tree being copied or moved, and is not modified as part of the operation
Missing : The Target file/folder is not present in the Target Path Location (in the link/junction/shortcut)
Working Directory : Shortcuts have metadata that holds the path to a working directory. This can be internal or external, or missing.
Target : The file or folder referenced by a link, junction, symbolic link, or shortcut.
Internal/External classification is based on the pathname, not whether the target currently exists or not.
CrazyCopy's Treatment of Target Paths and Working Directories
Targets are represented by paths which can be either relative or absolute. Shortcut (.lnk) files have a Working Directory path and a target path, and these files can target a file or folder. Shortcut Target Paths are stored as absolute paths in Windows. If relative paths were used during creation then they will have been converted to absolute. Shortcut Working Directories on the other hand, can be specified with either relative or absolute paths.
These rules have been created to remove the intricate and complex decision making behind special files when moving and copying. CrazyCopy removes these decisions from the user, and does what's best for the folder being copied or moved.
During an operation CrazyCopy:
- Continues to ensure all links and shortcuts work (if they were working originally)
- Retains the original intention when the special files were created. For example keeping relative paths as relative unless that results in breaking rule 1. In this case, relative paths will be converted to absolute paths
- Retains the original intention when the files were created by keeping all absolute paths
Hardlinks (mklink /H) that are copied or moved become independent normal files.
Internal Relative paths are preserved, because the objects in the relationship retain their relative positions, so these will continue to work.
External Relative paths are converted to absolute paths pointing to the same external target.
Internal Absolute paths have their target remapped to the target's absolute new path in the destination folder. So these stay absolute but point at the new destination target.
External Absolute paths are preserved as the external files have not moved, and so the paths are still valid.
All External Target files/folders and External Working Directories remain untouched by operations. However, metadata containing an External Relative path may be converted to an absolute path.
If targets or Working Directories are missing before the operation begins, then it does not affect the above rules and the same remapping explained above, still applies. Links, Shortcuts and Junctions with missing Targets or missing Working Directories will be remapped if their paths are absolute and internal. If Targets or Working Directories are missing before the operation begins, this does not affect the above rules and the same remapping explained above still applies. This means if a link, shortcut or junction was pointing at a missing target file or folder, and was broken before the operation, it will continue to be broken after the copy or move operation.
Shortcuts with Internal Absolute Working Directories have their Working Directories remapped to the new path in the Destination Folder. They stay as absolute paths.
Shortcuts with Internal Relative Working Directories remain unchanged.
Likewise shortcuts with External Absolute Working Directories also remain unchanged.
Shortcuts with External Relative Working Directories have their Working Directories converted to absolute paths.
Copied or moved links and shortcuts with External Targets or External Working Directories, are not remapped to corresponding objects in the Destination tree, they continue to point to the same External Target.
|
Path To Target or Working Directory (.lnk) |
Action |
|---|---|
| Internal + Relative path | Preserve Relative path unchanged |
| Internal + Absolute path | Remap to new Destination with Absolute path |
| External + Relative path | Convert to Absolute path to same Target |
| External + Absolute path | Preserve Absolute path unchanged |
Quick Reference of Exact Behaviour per File Type
This table shows what object or location each special file refers to after the operation. It does not describe whether the stored pathname remains relative or absolute; those rules are shown in the previous table.
| File Type | Internal Target | External Target | Missing Target | Internal Working Directory | External Working Directory | Missing Working Directory |
|---|---|---|---|---|---|---|
| Normal File | N/A | N/A | N/A | N/A | N/A | N/A |
| Normal Folder | N/A | N/A | N/A | N/A | N/A | N/A |
|
File Shortcut
|
Target corresponding destination-tree file | Targets same external file | Existence does not matter: internal path → remap; external path → preserve | Target corresponding destination-tree folder | Target original external Working Directory | Existence does not matter: internal path → remap; external path → preserve |
|
Folder Shortcut
|
Target corresponding destination-tree folder | Targets same external folder | Existence does not matter: internal path → remap; external path → preserve | Target corresponding destination-tree folder | Target original external Working Directory | Existence does not matter: internal path → remap; external path → preserve |
Junction mklink /J |
Target corresponding destination-tree folder | Targets same external folder | Existence does not matter: internal path → remap; external path → preserve | N/A | N/A | N/A |
|
File Symbolic Link
|
Target corresponding destination-tree file | Targets same external file | Existence does not matter: internal path → remap; external path → preserve | N/A | N/A | N/A |
Hardlink mklink /H |
No target pathname to remap; copied as an independent normal file | Same — internal/external distinction does not apply | N/A — an existing hardlink is itself a valid file even if another hardlink name was deleted | N/A | N/A | N/A |
Directory Symbolic Link mklink /D |
Target corresponding destination-tree folder | Targets same external folder | Existence does not matter: internal path → remap; external path → preserve | N/A | N/A | N/A |