private int executeGenericPathInformationOperation(PathInformation pathInfo, bool mutableOperation, GenericPathInformationOperationDelegate operation) { if (pathInfo == null) { throw new ArgumentNullException("pathInfo"); } if (operation == null) { throw new ArgumentNullException("operation"); } Trace.TraceInformation("Executing operation on path " + pathInfo.RealPath); if (mutableOperation && pathInfo.ContainingMember.ReadOnly) { Trace.TraceInformation("Attempted to modify read-only object"); return -DokanNet.ERROR_ACCESS_DENIED; } try { operation.Invoke(pathInfo); } catch (ArgumentException e) { Trace.TraceWarning(String.Format("Operation on path {0} failed because: {1} (managed exception; no Win32 error code)", pathInfo.RealPath, e.Message)); return -2; } catch (Exception e) { int errorCode = AufsImpl.getLastError(); Trace.TraceWarning(String.Format("Operation on path {0} failed because: {1} (error code of {2})", pathInfo.RealPath, e.Message, errorCode)); return errorCode; } Trace.TraceInformation("Operation completed successfully"); return 0; }
private int executeGenericMultipleFileObjectOperation(IEnumerable<PathInformation> pathInfos, bool mutableOperation, GenericPathInformationOperationDelegate operation) { if (pathInfos == null) { throw new ArgumentNullException("pathInfos"); } if (operation == null) { throw new ArgumentNullException("operation"); } foreach (PathInformation pathInfo in pathInfos) { int result = this.executeGenericPathInformationOperation(pathInfo, mutableOperation, operation); if (result != 0) { return result; } } return 0; }