|
3 | 3 |
|
4 | 4 | using System; |
5 | 5 | using System.Collections.Generic; |
| 6 | +using System.ComponentModel; |
6 | 7 | using System.Diagnostics; |
7 | 8 | using System.IO; |
8 | 9 | using System.Linq; |
@@ -133,6 +134,35 @@ public async Task ReFSPositiveDetectionAndCloneFileCorrectBehavior(CloneFlags cl |
133 | 134 | string dest2Contents = await File.ReadAllTextAsync(dest2Path); |
134 | 135 | Assert.AreEqual("AABBCCDD", dest2Contents); |
135 | 136 |
|
| 137 | + // Clone a file with an Alternate Data Stream. |
| 138 | + string adsSource = Path.Combine(refsTestRoot, "AltDataStreamSource"); |
| 139 | + var adsSourceFI = new FileInfo(adsSource); |
| 140 | + await File.WriteAllTextAsync(adsSource, "aaaaa"); |
| 141 | + await File.WriteAllTextAsync(adsSource + ":x", "bbbbbbb"); |
| 142 | + string adsDest = Path.Combine(refsTestRoot, "AltDataStreamDestination"); |
| 143 | + cow.CloneFile(adsSource, adsDest, cloneFlags); |
| 144 | + Assert.IsTrue(File.Exists(adsDest)); |
| 145 | + var adsDestFI = new FileInfo(adsDest); |
| 146 | + Assert.AreEqual(adsSourceFI.Length, adsDestFI.Length); |
| 147 | + string adsDestContents = await File.ReadAllTextAsync(adsDest); |
| 148 | + Assert.AreEqual("aaaaa", adsDestContents); |
| 149 | + Assert.IsFalse(File.Exists(adsDest + ":x"), "Expect that the alt data stream was not cloned"); |
| 150 | + |
| 151 | + const int ERROR_NOT_SUPPORTED = 50; |
| 152 | + try |
| 153 | + { |
| 154 | + cow.CloneFile(source1Path, adsDest + ":x", cloneFlags); |
| 155 | + Assert.Fail("Expected ERROR_NOT_SUPPORTED exception. Has cloning an alt data stream been added in newer Windows?"); |
| 156 | + } |
| 157 | + catch (Win32Exception win32Ex) when (win32Ex.NativeErrorCode == ERROR_NOT_SUPPORTED) |
| 158 | + { |
| 159 | + // Expected. |
| 160 | + } |
| 161 | + catch (Exception ex) |
| 162 | + { |
| 163 | + Console.WriteLine(ex.ToString()); |
| 164 | + } |
| 165 | + |
136 | 166 | // TODO: Clone a hardlink and symlink. |
137 | 167 |
|
138 | 168 | // Delete original file, ensure clones remain materialized. |
|
0 commit comments