private HRESULT ProcessPlaceholderRequest( PRJ_CALLBACK_DATA callbackData ) { return(_asyncOperations.ProcessCommandPossibleAsync( callbackData.NamespaceVirtualizationContext, callbackData.CommandId, cts => FileSystem.GetPlaceholder( callbackData.FilePathName, s => _outboundFunctions.PrjFileNameMatch(s, callbackData.FilePathName), cts.Token), placeholder => { if (placeholder == null) { return HRESULT.ERROR_FILE_NOT_FOUND; } using (var buffer = LevelShifter.PRJ_PLACEHOLDER_INFOFromPlaceholderInfo(placeholder)) { var result = _outboundFunctions.PrjWritePlaceholderInfo(callbackData.NamespaceVirtualizationContext, placeholder.DestinationFileName, buffer.Buffer, buffer.Sizes.totalSize); return result; } } )); }
private HRESULT ProcessStartEnumeration( PRJ_CALLBACK_DATA callbackData, Guid enumerationId ) { try { var cts = new CancellationTokenSource(); var ongoing = new OngoingEnumeration { Path = callbackData.FilePathName, VersionInfo = LevelShifter.PlaceholderVersionFromPRJ_PLACEHOLDER_VERSION_INFO(callbackData.VersionInfo), State = EnumerationState.Init }; if (!_inFlightEnumerations.TryAdd(enumerationId, ongoing)) { cts.Cancel(); return(HRESULT.E_INVALIDARG); } return(HRESULT.S_OK); } catch (Exception) { return(HRESULT.E_INVALIDARG); } }
internal HRESULT ProcessDataRequest( PRJ_CALLBACK_DATA callbackData, ulong byteOffset, uint length ) { var weirdnessOffset = byteOffset % (ulong)_virtualizationInfo.WriteAlignment; byteOffset -= weirdnessOffset; length += (uint)weirdnessOffset; var stream = new FileWriteStream(byteOffset, _virtualizationInfo.WriteAlignment, callbackData.NamespaceVirtualizationContext, callbackData.DataStreamId, _outboundFunctions); return(_asyncOperations.ProcessCommandPossibleAsync( callbackData.NamespaceVirtualizationContext, callbackData.CommandId, cts => FileSystem.GetFileData( callbackData.FilePathName, LevelShifter.PlaceholderVersionFromPRJ_PLACEHOLDER_VERSION_INFO(callbackData.VersionInfo), (long)byteOffset, (int)length, stream).ContinueWith(t => { stream.Close(); }))); }
private bool SendCurrentEnumeratorValue(OngoingEnumeration ongoing, IntPtr dirEntryBufferHandle) { var current = ongoing.Enumerator.Current; if (_outboundFunctions.PrjFillDirEntryBuffer( current.Name, LevelShifter.PRJ_FILE_BASIC_INFOFromBasicInfo(current), dirEntryBufferHandle) == HRESULT.S_OK) { return(true); } return(false); }