{"id":1015,"date":"2011-03-05T15:13:34","date_gmt":"2011-03-05T13:13:34","guid":{"rendered":"http:\/\/neosmart.net\/blog\/?p=1015"},"modified":"2013-08-26T18:19:35","modified_gmt":"2013-08-26T23:19:35","slug":"open-source-100-compatible-ln-for-windows-and-junction-point-library","status":"publish","type":"post","link":"https:\/\/neosmart.net\/blog\/open-source-100-compatible-ln-for-windows-and-junction-point-library\/","title":{"rendered":"Open Source, 100% Compatible ln for Windows (and Junction Point library)"},"content":{"rendered":"<p>We&#8217;ve been huge fans of symlinks for forever, and even posted about Windows Vista&#8217;s <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/cc753194(WS.10).aspx\" rel=\"follow\">new mklink<\/a> commandline utility with <a href=\"https:\/\/neosmart.net\/blog\/symlinks-on-vista\/\" rel=\"follow\">quite the passion<\/a> back in 2006 when the ability to create soft-links from the commandline was first added to Windows.<\/p>\n<p>However, there are a few things that have forever irked us about the ln lookalike called mklink.exe:<\/p>\n<ul>\n<li>It&#8217;s called mklink and not ln. (I mean, you just get can&#8217;t get around that fact)<\/li>\n<li>The arguments are switched around. `mklink something_doesnt_exist actual_file` is just&#8230;&#8230;.. wrong!<\/li>\n<li>By default, mklink will create softlinks and not hardlinks. ln requires the \/h flag to create a hardlink.<\/li>\n<li>mklink isn&#8217;t smart enough to distinguish between files and folders. You need explicitly tell it via the commandline.<\/li>\n<li>Even then, mklink has <em>two <\/em>different switches depending on the type of directory link you want. \/D for softlink&#8217;d directories, and \/J for hardlink&#8217;d directories.<\/li>\n<li>mklink can&#8217;t be used outside of cmd.exe (such as in PowerShell). <small>(Hat tip: <a href=\"https:\/\/neosmart.net\/blog\/open-source-100-compatible-ln-for-windows-and-junction-point-library\/\" rel=\"follow\">Jason<\/a>)<\/small><\/li>\n<li>And, of course, \u00a0mklink isn&#8217;t open source.<\/li>\n<\/ul>\n<p>So we made our own.<\/p>\n<p><!--more--><\/p>\n<p>ln-win is available in 32-bit and 64-bit, uses the same syntax, names, switches, and argument ordering as ln on *nix. And pursuant to <a href=\"https:\/\/neosmart.net\/blog\/contributing-to-the-open-source-community\/\" rel=\"follow\">our promise<\/a> to contribute more to open source, ln-win and our Junction Point library is 100% open source, freely licensed under the generous terms of the MIT license.<\/p>\n<p>Perhaps more importantly, ln-win contains an open source Junction Point library. While Win32 APIs exist to create symlinks (on Vista and up), there is no API for creating hardlinks of any kind (for files or folders). The NeoSmart JunctionPoint library provides the following APIs:<\/p>\n<pre class=\"code\">\tbool CreateJunctionPoint(LPCTSTR origin, LPCTSTR junction);\r\n\tbool IsDirectoryJunction(LPCTSTR path);\r\n\tbool GetJunctionDestination(LPCTSTR path, OUT LPTSTR destination);\r\n\tbool DeleteJunctionPoint(LPCTSTR path);\r\n<\/pre>\n<p>As you can see, the NeoSmart JunctionPoint library provides all the APIs you need both to create and interact with hardlinks. IsDirectoryJunction can be used for both symlinks and hardlinks, making it a snap to make your code symlink\/hardlink aware, letting you intelligently avoid cyclic paths and data duplication for any filesystem traversal needs.<\/p>\n<p class=\"save\"><a href=\"http:\/\/neosmart.net\/Symlinks\/\" rel=\"follow\">Binaries for Windows x86 and x64<\/a><\/p>\n<p class=\"save\"><a href=\"https:\/\/github.com\/NeoSmart\/ln-win\" rel=\"nofollow\">ln-win Source Code on GitHub<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;ve been huge fans of symlinks for forever, and even posted about Windows Vista&#8217;s new mklink commandline utility with quite the passion back in 2006 when the ability to create soft-links from the commandline was first added to Windows. However, &hellip; <a href=\"https:\/\/neosmart.net\/blog\/open-source-100-compatible-ln-for-windows-and-junction-point-library\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[367,759,779,777,775,776,727,52,901,778],"class_list":["post-1015","post","type-post","status-publish","format-standard","hentry","category-software","tag-download","tag-github","tag-hardlink","tag-library","tag-ln","tag-ln-win","tag-neosmart","tag-open-source","tag-software","tag-symlink"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4xDa-gn","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts\/1015","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/comments?post=1015"}],"version-history":[{"count":6,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts\/1015\/revisions"}],"predecessor-version":[{"id":2659,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts\/1015\/revisions\/2659"}],"wp:attachment":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/media?parent=1015"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/categories?post=1015"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/tags?post=1015"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}