Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 169979 Details for
Bug 314448
[efs] deleting a file inside a non-readable non-executable folder fails without exception
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch v1
efsPlatformExists_v1.diff.txt (text/plain), 7.49 KB, created by
Martin Oberhuber
on 2010-05-26 08:51:13 EDT
(
hide
)
Description:
patch v1
Filename:
MIME Type:
Creator:
Martin Oberhuber
Created:
2010-05-26 08:51:13 EDT
Size:
7.49 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.filesystem >Index: natives/unix/unixfile.c >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.filesystem/natives/unix/unixfile.c,v >retrieving revision 1.2 >diff -u -r1.2 unixfile.c >--- natives/unix/unixfile.c 21 Jan 2010 16:12:55 -0000 1.2 >+++ natives/unix/unixfile.c 26 May 2010 12:45:00 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Martin Oberhuber (Wind River) - [314448] error on exists() for non-accessible > *******************************************************************************/ > > #include <stdlib.h> >@@ -138,6 +139,7 @@ > * Class: org_eclipse_core_internal_filesystem_local_unix_UnixFileNatives > * Method: lstat > * Signature: ([BLorg/eclipse/core/internal/filesystem/local/unix/StructStat;)I >+ * returns: 0 on success, -1 on error converting to Java, -2 if file does not exist, or errno code on file access error > */ > JNIEXPORT jint JNICALL Java_org_eclipse_core_internal_filesystem_local_unix_UnixFileNatives_lstat > (JNIEnv *env, jclass clazz, jbyteArray path, jobject buf) >@@ -151,8 +153,10 @@ > free(name); > if (code != -1) > return convertStatToObject(env, info, buf); >+ else if (errno == ENOENT) >+ return -2; /* file does not exist */ > else >- return code; >+ return errno; > } > > /* >Index: src/org/eclipse/core/internal/filesystem/local/LocalFile.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/LocalFile.java,v >retrieving revision 1.33 >diff -u -r1.33 LocalFile.java >--- src/org/eclipse/core/internal/filesystem/local/LocalFile.java 20 Jan 2010 15:20:58 -0000 1.33 >+++ src/org/eclipse/core/internal/filesystem/local/LocalFile.java 26 May 2010 12:45:00 -0000 >@@ -8,6 +8,7 @@ > * Contributors: > * IBM Corporation - initial API and implementation > * Martin Oberhuber (Wind River) - [294429] Avoid substring baggage in FileInfo >+ * Martin Oberhuber (Wind River) - [314448] error on exists() for non-accessible > *******************************************************************************/ > package org.eclipse.core.internal.filesystem.local; > >@@ -139,7 +140,7 @@ > return file.equals(otherFile.file); > } > >- public IFileInfo fetchInfo(int options, IProgressMonitor monitor) { >+ public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException { > if (LocalFileNativesManager.isUsingNatives()) { > FileInfo info = LocalFileNativesManager.fetchFileInfo(filePath); > //natives don't set the file name on all platforms >@@ -212,7 +213,7 @@ > if (monitor.isCanceled()) { > throw new OperationCanceledException(); > } >- if (target.delete() || !target.exists()) >+ if (target.delete()) > return true; > if (target.isDirectory()) { > monitor.subTask(NLS.bind(Messages.deleting, target)); >@@ -246,13 +247,20 @@ > return false; > } > } >- //if we got this far, we failed >+ //if we got this far, we failed or the file never existed > String message = null; >- if (fetchInfo().getAttribute(EFS.ATTRIBUTE_READ_ONLY)) >- message = NLS.bind(Messages.couldnotDeleteReadOnly, target.getAbsolutePath()); >- else >- message = NLS.bind(Messages.couldnotDelete, target.getAbsolutePath()); >- status.add(new Status(IStatus.ERROR, Policy.PI_FILE_SYSTEM, EFS.ERROR_DELETE, message, null)); >+ try { >+ IFileInfo info = fetchInfo(EFS.NONE, monitor); >+ if (!info.exists()) >+ return true; >+ else if (info.getAttribute(EFS.ATTRIBUTE_READ_ONLY)) >+ message = NLS.bind(Messages.couldnotDeleteReadOnly, target.getAbsolutePath()); >+ else >+ message = NLS.bind(Messages.couldnotDelete, target.getAbsolutePath()); >+ status.add(new Status(IStatus.ERROR, Policy.PI_FILE_SYSTEM, EFS.ERROR_DELETE, message, null)); >+ } catch (CoreException ce) { >+ status.add(ce.getStatus()); >+ } > return false; > } > >Index: src/org/eclipse/core/internal/filesystem/local/LocalFileNativesManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/LocalFileNativesManager.java,v >retrieving revision 1.2 >diff -u -r1.2 LocalFileNativesManager.java >--- src/org/eclipse/core/internal/filesystem/local/LocalFileNativesManager.java 15 Mar 2010 10:15:42 -0000 1.2 >+++ src/org/eclipse/core/internal/filesystem/local/LocalFileNativesManager.java 26 May 2010 12:45:01 -0000 >@@ -7,12 +7,14 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Martin Oberhuber (Wind River) - [314448] error on exists() for non-accessible > *******************************************************************************/ > package org.eclipse.core.internal.filesystem.local; > > import org.eclipse.core.filesystem.IFileInfo; > import org.eclipse.core.filesystem.provider.FileInfo; > import org.eclipse.core.internal.filesystem.local.unix.UnixFileNatives; >+import org.eclipse.core.runtime.CoreException; > > /** > * Dispatches methods backed by native code to the appropriate platform specific >@@ -26,7 +28,7 @@ > return LocalFileNatives.attributes(); > } > >- public static FileInfo fetchFileInfo(String fileName) { >+ public static FileInfo fetchFileInfo(String fileName) throws CoreException { > if (UnixFileNatives.isUsingNatives()) > return UnixFileNatives.fetchFileInfo(fileName); > return LocalFileNatives.fetchFileInfo(fileName); >Index: src/org/eclipse/core/internal/filesystem/local/unix/UnixFileNatives.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/unix/UnixFileNatives.java,v >retrieving revision 1.2 >diff -u -r1.2 UnixFileNatives.java >--- src/org/eclipse/core/internal/filesystem/local/unix/UnixFileNatives.java 15 Mar 2010 10:15:42 -0000 1.2 >+++ src/org/eclipse/core/internal/filesystem/local/unix/UnixFileNatives.java 26 May 2010 12:45:01 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Martin Oberhuber (Wind River) - [314448] error on exists() for non-accessible > *******************************************************************************/ > package org.eclipse.core.internal.filesystem.local.unix; > >@@ -17,7 +18,7 @@ > import org.eclipse.core.filesystem.provider.FileInfo; > import org.eclipse.core.internal.filesystem.*; > import org.eclipse.core.internal.filesystem.local.Convert; >-import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.*; > import org.eclipse.osgi.util.NLS; > > public abstract class UnixFileNatives { >@@ -66,11 +67,12 @@ > return ret; > } > >- public static FileInfo fetchFileInfo(String fileName) { >+ public static FileInfo fetchFileInfo(String fileName) throws CoreException { > FileInfo info = null; > byte[] name = fileNameToBytes(fileName); > StructStat stat = new StructStat(); >- if (lstat(name, stat) == 0) { >+ int errno = lstat(name, stat); >+ if (errno == 0) { > if ((stat.st_mode & UnixFileFlags.S_IFMT) == UnixFileFlags.S_IFLNK) { > if (stat(name, stat) == 0) > info = stat.toFileInfo(); >@@ -83,8 +85,12 @@ > info.setStringAttribute(EFS.ATTRIBUTE_LINK_TARGET, bytesToFileName(target, (int) length)); > } else > info = stat.toFileInfo(); >- } else >+ } else if (errno == -2) { >+ //file does not exist > info = new FileInfo(); >+ } else { >+ throw new CoreException(new Status(IStatus.ERROR, Policy.PI_FILE_SYSTEM, EFS.ERROR_READ, "errno: " + info, null)); //$NON-NLS-1$ >+ } > return info; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 314448
: 169979