@@ -759,30 +759,32 @@ pub fn readlink(path: &Path) -> io::Result<PathBuf> {
759759 file. readlink ( )
760760}
761761
762- pub fn symlink ( src : & Path , dst : & Path ) -> io:: Result < ( ) > {
763- symlink_inner ( src , dst , false )
762+ pub fn symlink ( original : & Path , link : & Path ) -> io:: Result < ( ) > {
763+ symlink_inner ( original , link , false )
764764}
765765
766- pub fn symlink_inner ( src : & Path , dst : & Path , dir : bool ) -> io:: Result < ( ) > {
767- let src = to_u16s ( src ) ?;
768- let dst = to_u16s ( dst ) ?;
766+ pub fn symlink_inner ( original : & Path , link : & Path , dir : bool ) -> io:: Result < ( ) > {
767+ let original = to_u16s ( original ) ?;
768+ let link = to_u16s ( link ) ?;
769769 let flags = if dir { c:: SYMBOLIC_LINK_FLAG_DIRECTORY } else { 0 } ;
770770 // Formerly, symlink creation required the SeCreateSymbolicLink privilege. For the Windows 10
771771 // Creators Update, Microsoft loosened this to allow unprivileged symlink creation if the
772772 // computer is in Developer Mode, but SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE must be
773773 // added to dwFlags to opt into this behaviour.
774774 let result = cvt ( unsafe {
775775 c:: CreateSymbolicLinkW (
776- dst . as_ptr ( ) ,
777- src . as_ptr ( ) ,
776+ link . as_ptr ( ) ,
777+ original . as_ptr ( ) ,
778778 flags | c:: SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE ,
779779 ) as c:: BOOL
780780 } ) ;
781781 if let Err ( err) = result {
782782 if err. raw_os_error ( ) == Some ( c:: ERROR_INVALID_PARAMETER as i32 ) {
783783 // Older Windows objects to SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE,
784784 // so if we encounter ERROR_INVALID_PARAMETER, retry without that flag.
785- cvt ( unsafe { c:: CreateSymbolicLinkW ( dst. as_ptr ( ) , src. as_ptr ( ) , flags) as c:: BOOL } ) ?;
785+ cvt ( unsafe {
786+ c:: CreateSymbolicLinkW ( link. as_ptr ( ) , original. as_ptr ( ) , flags) as c:: BOOL
787+ } ) ?;
786788 } else {
787789 return Err ( err) ;
788790 }
@@ -791,15 +793,15 @@ pub fn symlink_inner(src: &Path, dst: &Path, dir: bool) -> io::Result<()> {
791793}
792794
793795#[ cfg( not( target_vendor = "uwp" ) ) ]
794- pub fn link ( src : & Path , dst : & Path ) -> io:: Result < ( ) > {
795- let src = to_u16s ( src ) ?;
796- let dst = to_u16s ( dst ) ?;
797- cvt ( unsafe { c:: CreateHardLinkW ( dst . as_ptr ( ) , src . as_ptr ( ) , ptr:: null_mut ( ) ) } ) ?;
796+ pub fn link ( original : & Path , link : & Path ) -> io:: Result < ( ) > {
797+ let original = to_u16s ( original ) ?;
798+ let link = to_u16s ( link ) ?;
799+ cvt ( unsafe { c:: CreateHardLinkW ( link . as_ptr ( ) , original . as_ptr ( ) , ptr:: null_mut ( ) ) } ) ?;
798800 Ok ( ( ) )
799801}
800802
801803#[ cfg( target_vendor = "uwp" ) ]
802- pub fn link ( _src : & Path , _dst : & Path ) -> io:: Result < ( ) > {
804+ pub fn link ( _original : & Path , _link : & Path ) -> io:: Result < ( ) > {
803805 return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "hard link are not supported on UWP" ) ) ;
804806}
805807
@@ -883,8 +885,11 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
883885}
884886
885887#[ allow( dead_code) ]
886- pub fn symlink_junction < P : AsRef < Path > , Q : AsRef < Path > > ( src : P , dst : Q ) -> io:: Result < ( ) > {
887- symlink_junction_inner ( src. as_ref ( ) , dst. as_ref ( ) )
888+ pub fn symlink_junction < P : AsRef < Path > , Q : AsRef < Path > > (
889+ original : P ,
890+ junction : Q ,
891+ ) -> io:: Result < ( ) > {
892+ symlink_junction_inner ( original. as_ref ( ) , junction. as_ref ( ) )
888893}
889894
890895// Creating a directory junction on windows involves dealing with reparse
@@ -893,7 +898,7 @@ pub fn symlink_junction<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::R
893898//
894899// http://www.flexhex.com/docs/articles/hard-links.phtml
895900#[ allow( dead_code) ]
896- fn symlink_junction_inner ( target : & Path , junction : & Path ) -> io:: Result < ( ) > {
901+ fn symlink_junction_inner ( original : & Path , junction : & Path ) -> io:: Result < ( ) > {
897902 let d = DirBuilder :: new ( ) ;
898903 d. mkdir ( & junction) ?;
899904
@@ -911,7 +916,7 @@ fn symlink_junction_inner(target: &Path, junction: &Path) -> io::Result<()> {
911916 // FIXME: this conversion is very hacky
912917 let v = br"\??\" ;
913918 let v = v. iter ( ) . map ( |x| * x as u16 ) ;
914- for c in v. chain ( target . as_os_str ( ) . encode_wide ( ) ) {
919+ for c in v. chain ( original . as_os_str ( ) . encode_wide ( ) ) {
915920 * buf. offset ( i) = c;
916921 i += 1 ;
917922 }
0 commit comments