Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 23, 2025

This PR cherry-picks commit d5d4f7e68512618ece8cd3374a66b999ae16dbda from the AdvancedSharpAdbClient branch, which introduces significant improvements to Virtual File Data Object (VFDO) stream handling.

Changes Overview

The main improvement is that FileContents IStream is now created directly from temporary files, eliminating the need for intermediate stream copying and improving performance for drag-and-drop operations.

Key Technical Changes

Before: Stream contents were handled through Action<Stream> delegates that would read from files and write to provided streams using buffer copying:

StreamContents = stream =>
{
    using (FileStream fs = new(file, FileMode.Open, FileAccess.Read))
    {
        byte[] buffer = new byte[81920];
        int read = 0;
        while ((read = fs.Read(buffer, 0, buffer.Length)) > 0)
        {
            stream.Write(buffer, 0, read);
        }
    }
}

After: Stream contents use a new delegate that returns IStream directly from files:

Stream = () =>
{
    // Direct IStream creation from file path
    return NativeMethods.CreateStreamOnFile(file);
}

Files Modified

  • FileClass.cs: Updated StreamContents property to new Stream delegate type
  • FileDescriptor.cs: Added StreamContents delegate definition and updated property types
  • VirtualFileDataObject.cs: Updated stream handling methods to use new delegate types
  • DragDropNative.cs: Added CreateStreamOnFile method using SHCreateStreamOnFileEx

Benefits

  1. Performance: Eliminates buffer copying by creating IStream directly from files
  2. Memory Usage: Reduces memory overhead from intermediate buffering
  3. Simplicity: Removes complex dialog handling and progress tracking from stream operations
  4. Reliability: Uses native Windows shell APIs for optimal compatibility

Original Commit Details

  • Commit: d5d4f7e
  • Author: alexSSB alexssb@live.com
  • Date: Tue Sep 23 22:10:30 2025 +0300
  • Branch: AdvancedSharpAdbClient

This cherry-pick brings these improvements to the master branch while preserving the original commit authorship and timestamp.

This pull request was created as a result of the following prompt from Copilot chat.

Cherry-pick commit d5d4f7e ("Improved VFDO stream handling") onto the master branch of Alex4SSB/ADB-Explorer.

  • The commit is currently not present in master and is 2 commits ahead.
  • Create a new branch from the latest master.
  • Cherry-pick only commit d5d4f7e.
  • Resolve any conflicts if necessary.
  • Open a pull request targeting master referencing the original commit.

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Alex4SSB Alex4SSB closed this Sep 23, 2025
@Alex4SSB Alex4SSB deleted the copilot/fix-abb71f3c-8dc3-4c7a-b9d0-dd7f56a9951d branch September 23, 2025 19:49
Copilot AI changed the title [WIP] Cherry-pick d5d4f7e68512618ece8cd3374a66b999ae16dbda onto master Cherry-pick: Improved VFDO stream handling from AdvancedSharpAdbClient branch Sep 23, 2025
Copilot AI requested a review from Alex4SSB September 23, 2025 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants