Skip to content

Commit

Permalink
Extend SyncCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
wherewhere committed Mar 12, 2024
1 parent e1ffbfc commit b607b97
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
6 changes: 3 additions & 3 deletions AdvancedSharpAdbClient.Tests/Models/ShellStreamTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public void ConstructorTest()
using MemoryStream stream = new();
using ShellStream shellStream = new(stream, false);
Assert.Equal(stream, shellStream.Inner);
Assert.True(shellStream.CanRead);
Assert.False(shellStream.CanSeek);
Assert.False(shellStream.CanWrite);
Assert.Equal(stream.CanRead, shellStream.CanRead);
Assert.Equal(stream.CanSeek, shellStream.CanSeek);
Assert.Equal(stream.CanWrite, shellStream.CanWrite);
}

[Fact]
Expand Down
10 changes: 1 addition & 9 deletions AdvancedSharpAdbClient/Extensions/SyncCommandConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@ public static byte[] GetBytes(this SyncCommand command)
return [0, 0, 0, 0];
}

if (command is not (SyncCommand.LIST
or SyncCommand.RECV
or SyncCommand.SEND
or SyncCommand.STAT
or SyncCommand.DENT
or SyncCommand.FAIL
or SyncCommand.DATA
or SyncCommand.OKAY
or SyncCommand.DONE))
if (command is < SyncCommand.STAT or > SyncCommand.LST2)
{
throw new ArgumentOutOfRangeException(nameof(command), $"{command} is not a valid sync command");
}
Expand Down
35 changes: 25 additions & 10 deletions AdvancedSharpAdbClient/Models/Enums/SyncCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@ namespace AdvancedSharpAdbClient.Models
public enum SyncCommand
{
/// <summary>
/// List the files in a folder.
/// Stat a file.
/// </summary>
LIST = 1,
STAT = 1,

/// <summary>
/// Retrieve a file from device.
/// List the files in a folder.
/// </summary>
RECV,
LIST,

/// <summary>
/// Send a file to device.
/// </summary>
SEND,

/// <summary>
/// Stat a file.
/// Retrieve a file from device.
/// </summary>
STAT,
RECV,

/// <summary>
/// A directory entry.
/// </summary>
DENT,

/// <summary>
/// The operation has failed.
/// The operation has completed.
/// </summary>
FAIL,
DONE,

/// <summary>
/// Marks the start of a data packet.
Expand All @@ -50,8 +50,23 @@ public enum SyncCommand
OKAY,

/// <summary>
/// The operation has completed.
/// The operation has failed.
/// </summary>
FAIL,

/// <summary>
/// The server has acknowledged the request.
/// </summary>
QUIT,

/// <summary>
/// Stat a file v2.
/// </summary>
STA2,

/// <summary>
/// Stat a list v2.
/// </summary>
DONE
LST2
}
}

0 comments on commit b607b97

Please sign in to comment.