@@ -137,3 +137,52 @@ async fn test_symlink() {
137
137
let symlink_meta = compio_fs:: symlink_metadata ( dst. clone ( ) ) . await . unwrap ( ) ;
138
138
assert ! ( symlink_meta. file_type( ) . is_symlink( ) ) ;
139
139
}
140
+
141
+ #[ compio_macros:: test]
142
+ #[ cfg( windows) ]
143
+ async fn symlink_file_windows ( ) {
144
+ let dir = tempfile:: tempdir ( ) . unwrap ( ) ;
145
+
146
+ let source_path = dir. path ( ) . join ( "foo.txt" ) ;
147
+ let dest_path = dir. path ( ) . join ( "bar.txt" ) ;
148
+
149
+ compio_fs:: write ( & source_path, b"Hello File!" )
150
+ . await
151
+ . unwrap ( ) ;
152
+ compio_fs:: symlink_file ( & source_path, & dest_path)
153
+ . await
154
+ . unwrap ( ) ;
155
+
156
+ compio_fs:: write ( & source_path, b"new data!" ) . await . unwrap ( ) ;
157
+
158
+ let from = compio_fs:: read ( & source_path) . await . unwrap ( ) ;
159
+ let to = compio_fs:: read ( & dest_path) . await . unwrap ( ) ;
160
+
161
+ assert_eq ! ( from, to) ;
162
+ }
163
+
164
+ #[ compio_macros:: test]
165
+ #[ cfg( windows) ]
166
+ async fn symlink_dir_windows ( ) {
167
+ const FILE_NAME : & str = "abc.txt" ;
168
+
169
+ let temp_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
170
+
171
+ let dir1 = temp_dir. path ( ) . join ( "a" ) ;
172
+ compio_fs:: create_dir ( & dir1) . await . unwrap ( ) ;
173
+
174
+ let file1 = dir1. as_path ( ) . join ( FILE_NAME ) ;
175
+ compio_fs:: write ( & file1, b"Hello File!" ) . await . unwrap ( ) ;
176
+
177
+ let dir2 = temp_dir. path ( ) . join ( "b" ) ;
178
+ compio_fs:: symlink_dir ( & dir1, & dir2) . await . unwrap ( ) ;
179
+
180
+ compio_fs:: write ( & file1, b"new data!" ) . await . unwrap ( ) ;
181
+
182
+ let file2 = dir2. as_path ( ) . join ( FILE_NAME ) ;
183
+
184
+ let from = compio_fs:: read ( & file1) . await . unwrap ( ) ;
185
+ let to = compio_fs:: read ( & file2) . await . unwrap ( ) ;
186
+
187
+ assert_eq ! ( from, to) ;
188
+ }
0 commit comments