@Test public void testSymlink() throws Exception { final Local target = new Local(PreferencesFactory.get().getProperty("tmp.dir"), UUID.randomUUID().toString()); new DefaultLocalTouchFeature().touch(target); final Local symlink = new Local(PreferencesFactory.get().getProperty("tmp.dir"), UUID.randomUUID().toString()); assertFalse(symlink.exists()); new WorkspaceSymlinkFeature().symlink(symlink, target.getAbsolute()); assertTrue(symlink.exists()); target.delete(); symlink.delete(); }
@Override public void symlink(final Local file, final String target) throws AccessDeniedException { final ObjCObjectByReference error = new ObjCObjectByReference(); final boolean success = NSFileManager.defaultManager().createSymbolicLinkAtPath_withDestinationPath_error( file.getAbsolute(), target, error); if(!success) { final NSError f = error.getValueAs(NSError.class); if(null == f) { throw new LocalAccessDeniedException(String.format("%s %s", LocaleFactory.localizedString("Cannot create file", "Error"), file.getAbsolute())); } throw new LocalAccessDeniedException(String.format("%s", f.localizedDescription())); } if(log.isDebugEnabled()) { log.debug(String.format("Created symbolic link %s with target %s", file, target)); } }
WorkspaceSymlinkFeature implements Symlink { @Override public void symlink(final Local file, final String target) throws AccessDeniedException { final ObjCObjectByReference error = new ObjCObjectByReference(); final boolean success = NSFileManager.defaultManager().createSymbolicLinkAtPath_withDestinationPath_error( file.getAbsolute(), target, error); if(!success) { final NSError f = error.getValueAs(NSError.class); if(null == f) { throw new LocalAccessDeniedException(String.format("%s %s", LocaleFactory.localizedString("Cannot create file", "Error"), file.getAbsolute())); } throw new LocalAccessDeniedException(String.format("%s", f.localizedDescription())); } if(log.isDebugEnabled()) { log.debug(String.format("Created symbolic link %s with target %s", file, target)); } } }
WorkspaceSymlinkFeature implements Symlink { @Override public void symlink(final Local file, final String target) throws AccessDeniedException { final ObjCObjectByReference error = new ObjCObjectByReference(); final boolean success = NSFileManager.defaultManager().createSymbolicLinkAtPath_withDestinationPath_error( file.getAbsolute(), target, error); if(!success) { final NSError f = error.getValueAs(NSError.class); if(null == f) { throw new LocalAccessDeniedException(String.format("%s %s", LocaleFactory.localizedString("Cannot create file", "Error"), file.getAbsolute())); } throw new LocalAccessDeniedException(String.format("%s", f.localizedDescription())); } if(log.isDebugEnabled()) { log.debug(String.format("Created symbolic link %s with target %s", file, target)); } }  }
WorkspaceSymlinkFeature implements Symlink { @Override public void symlink(final Local file, final String target) throws AccessDeniedException { final ObjCObjectByReference error = new ObjCObjectByReference(); final boolean success = NSFileManager.defaultManager().createSymbolicLinkAtPath_withDestinationPath_error( file.getAbsolute(), target, error); if(!success) { final NSError f = error.getValueAs(NSError.class); if(null == f) { throw new LocalAccessDeniedException(String.format("%s %s", LocaleFactory.localizedString("Cannot create file", "Error"), file.getAbsolute())); } throw new LocalAccessDeniedException(String.format("%s", f.localizedDescription())); } if(log.isDebugEnabled()) { log.debug(String.format("Created symbolic link %s with target %s", file, target)); } }  @Override void symlink(final Local file, final String target); }
WorkspaceSymlinkFeature implements Symlink { @Override public void symlink(final Local file, final String target) throws AccessDeniedException { final ObjCObjectByReference error = new ObjCObjectByReference(); final boolean success = NSFileManager.defaultManager().createSymbolicLinkAtPath_withDestinationPath_error( file.getAbsolute(), target, error); if(!success) { final NSError f = error.getValueAs(NSError.class); if(null == f) { throw new LocalAccessDeniedException(String.format("%s %s", LocaleFactory.localizedString("Cannot create file", "Error"), file.getAbsolute())); } throw new LocalAccessDeniedException(String.format("%s", f.localizedDescription())); } if(log.isDebugEnabled()) { log.debug(String.format("Created symbolic link %s with target %s", file, target)); } }  @Override void symlink(final Local file, final String target);  }