//hardlink 硬链接
namespace fsys.hardlink;

CreateHardLink = ::Kernel32.api( "CreateHardLink", "int(ustring path,ustring exist,pointer sa)");	
GetFileAttributes = ::Kernel32.api("GetFileAttributes","int(ustring path)")

create = function(path,exist){ 
	path = ..io.fullpath(path)
	exist = ..io.exist(exist)
	
	if(! ..io.exist(exist) )
		error("参数二指定的文件不存在",2)
	if(..string.cmp(path,exist,2)!=0)
		error("硬链接路径必须位于同一分区",2)
	if( GetFileAttributes(exist) & 0x10/*_FILE_ATTRIBUTE_DIRECTORY*/ )
		error("不能为目录创建硬链接",2)
		
	if(! CreateHardLink(path,exist ) )
		error(  ..lasterr(),2);
}

/**intellisense(fsys.hardlink)
create("__/*指定硬链接文件路径*/","") = 创建硬链接
end intellisense**/


