1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-04 23:55:26 +02:00

[209593] clone permissions for modification purposes

This commit is contained in:
David McKnight 2008-01-22 23:13:13 +00:00
parent 403085ca50
commit 739dc3ac37
4 changed files with 32 additions and 13 deletions

View file

@ -351,57 +351,60 @@ public class SystemFilePermissionsPropertyPage extends SystemBasePropertyPage {
if ((capabilities & IFilePermissionsService.FS_CAN_SET_PERMISSIONS) != 0){
try
{
IHostFilePermissions newPermissions = _permissions.clone(_permissions);
if (_permissions.getPermission(IHostFilePermissions.PERM_USER_READ) != _userRead.getSelection()){
changed = true;
_permissions.setPermission(IHostFilePermissions.PERM_USER_READ, _userRead.getSelection());
newPermissions.setPermission(IHostFilePermissions.PERM_USER_READ, _userRead.getSelection());
}
if (_permissions.getPermission(IHostFilePermissions.PERM_USER_WRITE) != _userWrite.getSelection()){
changed = true;
_permissions.setPermission(IHostFilePermissions.PERM_USER_WRITE, _userWrite.getSelection());
newPermissions.setPermission(IHostFilePermissions.PERM_USER_WRITE, _userWrite.getSelection());
}
if (_permissions.getPermission(IHostFilePermissions.PERM_USER_EXECUTE) != _userExecute.getSelection()){
changed = true;
_permissions.setPermission(IHostFilePermissions.PERM_USER_EXECUTE, _userExecute.getSelection());
newPermissions.setPermission(IHostFilePermissions.PERM_USER_EXECUTE, _userExecute.getSelection());
}
if (_permissions.getPermission(IHostFilePermissions.PERM_GROUP_READ) != _groupRead.getSelection()){
changed = true;
_permissions.setPermission(IHostFilePermissions.PERM_GROUP_READ, _groupRead.getSelection());
newPermissions.setPermission(IHostFilePermissions.PERM_GROUP_READ, _groupRead.getSelection());
}
if (_permissions.getPermission(IHostFilePermissions.PERM_GROUP_WRITE) != _groupWrite.getSelection()){
changed = true;
_permissions.setPermission(IHostFilePermissions.PERM_GROUP_WRITE, _groupWrite.getSelection());
newPermissions.setPermission(IHostFilePermissions.PERM_GROUP_WRITE, _groupWrite.getSelection());
}
if (_permissions.getPermission(IHostFilePermissions.PERM_GROUP_EXECUTE) != _groupExecute.getSelection()){
changed = true;
_permissions.setPermission(IHostFilePermissions.PERM_GROUP_EXECUTE, _groupExecute.getSelection());
newPermissions.setPermission(IHostFilePermissions.PERM_GROUP_EXECUTE, _groupExecute.getSelection());
}
if (_permissions.getPermission(IHostFilePermissions.PERM_OTHER_READ) != _otherRead.getSelection()){
changed = true;
_permissions.setPermission(IHostFilePermissions.PERM_OTHER_READ, _otherRead.getSelection());
newPermissions.setPermission(IHostFilePermissions.PERM_OTHER_READ, _otherRead.getSelection());
}
if (_permissions.getPermission(IHostFilePermissions.PERM_OTHER_WRITE) != _otherWrite.getSelection()){
changed = true;
_permissions.setPermission(IHostFilePermissions.PERM_OTHER_WRITE, _otherWrite.getSelection());
newPermissions.setPermission(IHostFilePermissions.PERM_OTHER_WRITE, _otherWrite.getSelection());
}
if (_permissions.getPermission(IHostFilePermissions.PERM_OTHER_EXECUTE) != _otherExecute.getSelection()){
changed = true;
_permissions.setPermission(IHostFilePermissions.PERM_OTHER_EXECUTE, _otherExecute.getSelection());
newPermissions.setPermission(IHostFilePermissions.PERM_OTHER_EXECUTE, _otherExecute.getSelection());
}
if (_owner != _userEntry.getText()){
changed = true;
_permissions.setUserOwner(_userEntry.getText());
newPermissions.setUserOwner(_userEntry.getText());
}
if (_group != _groupEntry.getText()){
changed = true;
_permissions.setGroupOwner(_groupEntry.getText());
newPermissions.setGroupOwner(_groupEntry.getText());
}
if (changed){
service.setFilePermissions(remoteFile.getHostFile(), _permissions, new NullProgressMonitor());
// assuming permissions are good
service.setFilePermissions(remoteFile.getHostFile(), newPermissions, new NullProgressMonitor());
_permissions = newPermissions;
}
}
catch (Exception e){

View file

@ -81,6 +81,7 @@ import org.eclipse.rse.services.files.IFileService;
import org.eclipse.rse.services.files.IFileServiceCodePageConverter;
import org.eclipse.rse.services.files.IHostFile;
import org.eclipse.rse.services.files.IHostFilePermissions;
import org.eclipse.rse.services.files.IHostFilePermissionsContainer;
import org.eclipse.rse.services.files.PendingHostFilePermissions;
import org.eclipse.rse.services.files.RemoteFileSecurityException;
@ -2143,6 +2144,10 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
if (status != null)
{
// check status to make sure the file really changed
if (file instanceof IHostFilePermissionsContainer){
((IHostFilePermissionsContainer)file).setPermissions(permissions); // set to use new permissions
}
}
}

View file

@ -154,4 +154,9 @@ public class HostFilePermissions implements
public void setUserOwner(String user) {
_user = user;
}
public IHostFilePermissions clone(IHostFilePermissions toClone) {
IHostFilePermissions clone = new HostFilePermissions(toClone.getPermissionBits(), toClone.getUserOwner(), toClone.getGroupOwner());
return clone;
}
}

View file

@ -144,4 +144,10 @@ public interface IHostFilePermissions {
*/
public void setGroupOwner(String group);
/**
* Create a duplicate of a set of permissions
* @param toClone
* @return the duplicate
*/
public IHostFilePermissions clone(IHostFilePermissions toClone);
}