1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-03 15:15:25 +02:00

[199548] Avoid touching files on setReadOnly() if unnecessary

This commit is contained in:
Martin Oberhuber 2007-08-10 11:26:58 +00:00
parent e6c60f0c72
commit 28eefd9eff
4 changed files with 20 additions and 13 deletions

View file

@ -21,6 +21,7 @@
* Kevin Doyle (IBM) - [196211] DStore Move tries rename if that fails copy/delete
* Xuan Chen (IBM) - [198046] [dstore] Cannot copy a folder into an archive file
* Xuan Chen (IBM) - [191367] with supertransfer on, Drag & Drop Folder from DStore to DStore doesn't work
* Martin Oberhuber (Wind River) - [199548] Avoid touching files on setReadOnly() if unnecessary
*******************************************************************************/
package org.eclipse.rse.dstore.universal.miners;
@ -1230,17 +1231,13 @@ public class UniversalFileSystemMiner extends Miner {
else {
try {
String str = subject.getAttribute(DE.A_SOURCE);
boolean readOnly = false;
if (str.equals("true")) //$NON-NLS-1$
{
readOnly = true;
}
else
{
readOnly = false;
}
boolean readOnly = "true".equals(str); //$NON-NLS-1$
boolean done = false;
if (readOnly)
if (readOnly != filename.canWrite())
{
done = true;
}
else if (readOnly)
{
done = filename.setReadOnly();
}

View file

@ -19,6 +19,7 @@
* David McKnight (IBM) - [192705] Exception needs to be thrown when rename fails
* Kevin Doyle (IBM) - [196211] Move a folder to a directory that contains a folder by that name errors
* Martin Oberhuber (Wind River) - [199394] Allow real files/folders containing String #virtual#
* Martin Oberhuber (Wind River) - [199548] Avoid touching files on setReadOnly() if unnecessary
********************************************************************************/
package org.eclipse.rse.internal.services.local.files;
@ -1358,6 +1359,12 @@ public class LocalFileService extends AbstractFileService implements IFileServic
boolean readOnly, IProgressMonitor monitor) throws SystemMessageException
{
File file = new File(parent, name);
if (!file.exists()) {
return false;
}
if (readOnly != file.canWrite()) {
return true;
}
if (readOnly)
{
return file.setReadOnly();

View file

@ -11,6 +11,7 @@
* Kushal Munir (IBM) - for API bug
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Martin Oberhuber (Wind River) - [192724] Fixed logic to filter folders if FILE_TYPE_FOLDERS
* Martin Oberhuber (Wind River) - [199548] Avoid touching files on setReadOnly() if unnecessary
*******************************************************************************/
package org.eclipse.rse.internal.services.ssh.files;
@ -866,9 +867,9 @@ public class SftpFileService extends AbstractFileService implements IFileService
int permOld = attr.getPermissions();
int permNew = permOld;
if (readOnly) {
permNew &= ~128;
permNew &= ~(128 | 16 | 2); //ugo-w
} else {
permNew |= 128;
permNew |= 128; //u+w
}
if (permNew != permOld) {
//getChannel("SftpFileService.setReadOnly").chmod(permNew, path); //$NON-NLS-1$
@ -877,6 +878,7 @@ public class SftpFileService extends AbstractFileService implements IFileService
ok=true;
Activator.trace("SftpFileService.setReadOnly ok"); //$NON-NLS-1$
} else {
ok=true;
Activator.trace("SftpFileService.setReadOnly nothing-to-do"); //$NON-NLS-1$
}
} catch (Exception e) {

View file

@ -13,6 +13,7 @@
* Contributors:
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem
* Martin Oberhuber (Wind River) - [199548] Avoid touching files on setReadOnly() if unnecessary
********************************************************************************/
package org.eclipse.rse.services.files;
@ -288,7 +289,7 @@ public interface IFileService extends IService
* @param name the name of the file to set
* @param readOnly indicates whether to make the file readonly or read-write
* @param monitor the progress monitor
* @return true if the readonly permission was changed successfully
* @return true if the readonly permission was changed successfully, or the permission already was as desired
*/
public boolean setReadOnly(String parent, String name, boolean readOnly, IProgressMonitor monitor) throws SystemMessageException;