diff --git a/AdvancedSharpAdbClient.Tests/AdbSocketTests.Async.cs b/AdvancedSharpAdbClient.Tests/AdbSocketTests.Async.cs
index f2cfa1e..4980e6d 100644
--- a/AdvancedSharpAdbClient.Tests/AdbSocketTests.Async.cs
+++ b/AdvancedSharpAdbClient.Tests/AdbSocketTests.Async.cs
@@ -19,22 +19,22 @@ await RunTestAsync(
[(byte)'D', (byte)'A', (byte)'T', (byte)'A', 2, 0, 0, 0]);
///
- /// Tests the method.
+ /// Tests the method.
///
[Fact]
public async void SendSyncSENDRequestAsyncTest() =>
await RunTestAsync(
- socket => socket.SendSyncRequestAsync(SyncCommand.SEND, "/test", default),
- [(byte)'S', (byte)'E', (byte)'N', (byte)'D', 5, 0, 0, 0, (byte)'/', (byte)'t', (byte)'e', (byte)'s', (byte)'t']);
+ socket => socket.SendSyncRequestAsync(SyncCommand.SEND, "/test", UnixFileStatus.GroupMask | UnixFileStatus.StickyBit | UnixFileStatus.UserExecute | UnixFileStatus.OtherExecute, default),
+ [(byte)'S', (byte)'E', (byte)'N', (byte)'D', 9, 0, 0, 0, (byte)'/', (byte)'t', (byte)'e', (byte)'s', (byte)'t', (byte)',', (byte)'6', (byte)'3', (byte)'3']);
///
- /// Tests the method.
+ /// Tests the method.
///
[Fact]
public async void SendSyncDENTRequestAsyncTest() =>
await RunTestAsync(
- socket => socket.SendSyncRequestAsync(SyncCommand.DENT, "/data", 633, default),
- [(byte)'D', (byte)'E', (byte)'N', (byte)'T', 9, 0, 0, 0, (byte)'/', (byte)'d', (byte)'a', (byte)'t', (byte)'a', (byte)',', (byte)'6', (byte)'3', (byte)'3']);
+ socket => socket.SendSyncRequestAsync(SyncCommand.DENT, "/data", default),
+ [(byte)'D', (byte)'E', (byte)'N', (byte)'T', 5, 0, 0, 0, (byte)'/', (byte)'d', (byte)'a', (byte)'t', (byte)'a']);
///
/// Tests the method.
diff --git a/AdvancedSharpAdbClient.Tests/AdbSocketTests.cs b/AdvancedSharpAdbClient.Tests/AdbSocketTests.cs
index e6816be..91e4a54 100644
--- a/AdvancedSharpAdbClient.Tests/AdbSocketTests.cs
+++ b/AdvancedSharpAdbClient.Tests/AdbSocketTests.cs
@@ -63,22 +63,22 @@ public void SendSyncDATARequestTest() =>
[(byte)'D', (byte)'A', (byte)'T', (byte)'A', 2, 0, 0, 0]);
///
- /// Tests the method.
+ /// Tests the method.
///
[Fact]
public void SendSyncSENDRequestTest() =>
RunTest(
- socket => socket.SendSyncRequest(SyncCommand.SEND, "/test"),
- [(byte)'S', (byte)'E', (byte)'N', (byte)'D', 5, 0, 0, 0, (byte)'/', (byte)'t', (byte)'e', (byte)'s', (byte)'t']);
+ socket => socket.SendSyncRequest(SyncCommand.SEND, "/test", UnixFileStatus.GroupMask | UnixFileStatus.StickyBit | UnixFileStatus.UserExecute | UnixFileStatus.OtherExecute),
+ [(byte)'S', (byte)'E', (byte)'N', (byte)'D', 9, 0, 0, 0, (byte)'/', (byte)'t', (byte)'e', (byte)'s', (byte)'t', (byte)',', (byte)'6', (byte)'3', (byte)'3']);
///
- /// Tests the method.
+ /// Tests the method.
///
[Fact]
public void SendSyncDENTRequestTest() =>
RunTest(
- socket => socket.SendSyncRequest(SyncCommand.DENT, "/data", 633),
- [(byte)'D', (byte)'E', (byte)'N', (byte)'T', 9, 0, 0, 0, (byte)'/', (byte)'d', (byte)'a', (byte)'t', (byte)'a', (byte)',', (byte)'6', (byte)'3', (byte)'3']);
+ socket => socket.SendSyncRequest(SyncCommand.DENT, "/data"),
+ [(byte)'D', (byte)'E', (byte)'N', (byte)'T', 5, 0, 0, 0, (byte)'/', (byte)'d', (byte)'a', (byte)'t', (byte)'a']);
///
/// Tests the method.
diff --git a/AdvancedSharpAdbClient.Tests/AdvancedSharpAdbClient.Tests.csproj b/AdvancedSharpAdbClient.Tests/AdvancedSharpAdbClient.Tests.csproj
index ce41458..1bed860 100644
--- a/AdvancedSharpAdbClient.Tests/AdvancedSharpAdbClient.Tests.csproj
+++ b/AdvancedSharpAdbClient.Tests/AdvancedSharpAdbClient.Tests.csproj
@@ -24,7 +24,7 @@
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs b/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs
index 9fbf753..ee33b37 100644
--- a/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs
+++ b/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs
@@ -61,7 +61,7 @@ internal class DummyAdbSocket : IDummyAdbSocket
public void SendSyncRequest(SyncCommand command, int length) => SyncRequests.Add((command, length.ToString()));
- public void SendSyncRequest(SyncCommand command, string path, int permissions) => SyncRequests.Add((command, $"{path},{permissions}"));
+ public void SendSyncRequest(SyncCommand command, string path, UnixFileStatus permission) => SyncRequests.Add((command, $"{path},{(int)permission}"));
public void SendAdbRequest(string request) => Requests.Add(request);
@@ -192,10 +192,10 @@ public async ValueTask SendAsync(ReadOnlyMemory data, CancellationToken ca
Send(data.Span);
}
- public async Task SendSyncRequestAsync(SyncCommand command, string path, int permissions, CancellationToken cancellationToken = default)
+ public async Task SendSyncRequestAsync(SyncCommand command, string path, UnixFileStatus permission, CancellationToken cancellationToken = default)
{
await Task.Yield();
- SendSyncRequest(command, path, permissions);
+ SendSyncRequest(command, path, permission);
}
public async Task SendSyncRequestAsync(SyncCommand command, string path, CancellationToken cancellationToken = default)
diff --git a/AdvancedSharpAdbClient.Tests/Dummys/DummySyncService.cs b/AdvancedSharpAdbClient.Tests/Dummys/DummySyncService.cs
index a054e75..17a27e1 100644
--- a/AdvancedSharpAdbClient.Tests/Dummys/DummySyncService.cs
+++ b/AdvancedSharpAdbClient.Tests/Dummys/DummySyncService.cs
@@ -42,7 +42,7 @@ public async Task PullAsync(string remotePath, Stream stream, Action callback = null, in bool isCancelled = false)
+ public void Push(Stream stream, string remotePath, UnixFileStatus permission, DateTimeOffset timestamp, Action callback = null, in bool isCancelled = false)
{
for (int i = 0; i <= 100; i++)
{
@@ -54,7 +54,7 @@ public void Push(Stream stream, string remotePath, int permissions, DateTimeOffs
}
}
- public async Task PushAsync(Stream stream, string remotePath, int permissions, DateTimeOffset timestamp, Action callback = null, CancellationToken cancellationToken = default)
+ public async Task PushAsync(Stream stream, string remotePath, UnixFileStatus permission, DateTimeOffset timestamp, Action callback = null, CancellationToken cancellationToken = default)
{
for (int i = 0; i <= 100; i++)
{
diff --git a/AdvancedSharpAdbClient.Tests/Extensions/SyncCommandConverterTests.cs b/AdvancedSharpAdbClient.Tests/Extensions/SyncCommandConverterTests.cs
index 24ba2b3..d692fa6 100644
--- a/AdvancedSharpAdbClient.Tests/Extensions/SyncCommandConverterTests.cs
+++ b/AdvancedSharpAdbClient.Tests/Extensions/SyncCommandConverterTests.cs
@@ -1,7 +1,7 @@
using System;
using Xunit;
-namespace AdvancedSharpAdbClient.Tests
+namespace AdvancedSharpAdbClient.Models.Tests
{
///
/// Tests the class.
diff --git a/AdvancedSharpAdbClient.Tests/Extensions/UnixFileStatusExtensionsTests.cs b/AdvancedSharpAdbClient.Tests/Extensions/UnixFileStatusExtensionsTests.cs
new file mode 100644
index 0000000..cc26c3e
--- /dev/null
+++ b/AdvancedSharpAdbClient.Tests/Extensions/UnixFileStatusExtensionsTests.cs
@@ -0,0 +1,182 @@
+using Xunit;
+
+namespace AdvancedSharpAdbClient.Models.Tests
+{
+ ///
+ /// Tests the class.
+ ///
+ public class UnixFileStatusExtensionsTests
+ {
+ [Theory]
+ [InlineData((UnixFileStatus)0x7DAB, (UnixFileStatus)0x7000)]
+ [InlineData((UnixFileStatus)0x3D94, (UnixFileStatus)0x3000)]
+ [InlineData((UnixFileStatus)0x3052, (UnixFileStatus)0x3000)]
+ [InlineData((UnixFileStatus)0x8724, (UnixFileStatus)0x8000)]
+ [InlineData((UnixFileStatus)0xEBC3, (UnixFileStatus)0xE000)]
+ [InlineData((UnixFileStatus)0xBFBA, (UnixFileStatus)0xB000)]
+ [InlineData((UnixFileStatus)0x2059, (UnixFileStatus)0x2000)]
+ [InlineData((UnixFileStatus)0xAFDC, (UnixFileStatus)0xA000)]
+ [InlineData((UnixFileStatus)0x2D2F, (UnixFileStatus)0x2000)]
+ [InlineData((UnixFileStatus)0xC10F, (UnixFileStatus)0xC000)]
+ public void GetFileTypeTest(UnixFileStatus source, UnixFileStatus type) => Assert.Equal(type, source.GetFileType());
+
+ [Theory]
+ [InlineData((UnixFileStatus)0xF118, (UnixFileStatus)0x0118)]
+ [InlineData((UnixFileStatus)0x638A, (UnixFileStatus)0x038A)]
+ [InlineData((UnixFileStatus)0xB72D, (UnixFileStatus)0x072D)]
+ [InlineData((UnixFileStatus)0x5AF9, (UnixFileStatus)0x0AF9)]
+ [InlineData((UnixFileStatus)0xA3F5, (UnixFileStatus)0x03F5)]
+ [InlineData((UnixFileStatus)0x7ACD, (UnixFileStatus)0x0ACD)]
+ [InlineData((UnixFileStatus)0x4751, (UnixFileStatus)0x0751)]
+ [InlineData((UnixFileStatus)0xDA30, (UnixFileStatus)0x0A30)]
+ [InlineData((UnixFileStatus)0xB829, (UnixFileStatus)0x0829)]
+ [InlineData((UnixFileStatus)0xFE1A, (UnixFileStatus)0x0E1A)]
+ public void GetPermissionsTest(UnixFileStatus source, UnixFileStatus type) => Assert.Equal(type, source.GetPermissions());
+
+ [Theory]
+ [InlineData((UnixFileStatus)0x28DA, (UnixFileStatus)0x00DA)]
+ [InlineData((UnixFileStatus)0x69EE, (UnixFileStatus)0x01EE)]
+ [InlineData((UnixFileStatus)0x2507, (UnixFileStatus)0x0107)]
+ [InlineData((UnixFileStatus)0x763F, (UnixFileStatus)0x003F)]
+ [InlineData((UnixFileStatus)0x8ECC, (UnixFileStatus)0x00CC)]
+ [InlineData((UnixFileStatus)0xBFB8, (UnixFileStatus)0x01B8)]
+ [InlineData((UnixFileStatus)0xF893, (UnixFileStatus)0x0093)]
+ [InlineData((UnixFileStatus)0x8E54, (UnixFileStatus)0x0054)]
+ [InlineData((UnixFileStatus)0x6270, (UnixFileStatus)0x0070)]
+ [InlineData((UnixFileStatus)0x21AB, (UnixFileStatus)0x01AB)]
+ public void GetAccessPermissionsTest(UnixFileStatus source, UnixFileStatus type) => Assert.Equal(type, source.GetAccessPermissions());
+
+ [Theory]
+ [InlineData((UnixFileStatus)0x0FFF, false)]
+ [InlineData((UnixFileStatus)0x1FB6, false)]
+ [InlineData((UnixFileStatus)0x21FF, false)]
+ [InlineData((UnixFileStatus)0x41B6, true)]
+ [InlineData((UnixFileStatus)0x616D, false)]
+ [InlineData((UnixFileStatus)0x80DB, false)]
+ [InlineData((UnixFileStatus)0xA124, false)]
+ [InlineData((UnixFileStatus)0xC092, false)]
+ [InlineData((UnixFileStatus)0xF049, false)]
+ public void IsDirectoryTest(UnixFileStatus mode, bool result) => Assert.Equal(result, mode.IsDirectory());
+
+ [Theory]
+ [InlineData((UnixFileStatus)0x0FFF, false)]
+ [InlineData((UnixFileStatus)0x1FB6, false)]
+ [InlineData((UnixFileStatus)0x21FF, true)]
+ [InlineData((UnixFileStatus)0x41B6, false)]
+ [InlineData((UnixFileStatus)0x616D, false)]
+ [InlineData((UnixFileStatus)0x80DB, false)]
+ [InlineData((UnixFileStatus)0xA124, false)]
+ [InlineData((UnixFileStatus)0xC092, false)]
+ [InlineData((UnixFileStatus)0xF049, false)]
+ public void IsCharacterFileTest(UnixFileStatus mode, bool result) => Assert.Equal(result, mode.IsCharacterFile());
+
+ [Theory]
+ [InlineData((UnixFileStatus)0x0FFF, false)]
+ [InlineData((UnixFileStatus)0x1FB6, false)]
+ [InlineData((UnixFileStatus)0x21FF, false)]
+ [InlineData((UnixFileStatus)0x41B6, false)]
+ [InlineData((UnixFileStatus)0x616D, true)]
+ [InlineData((UnixFileStatus)0x80DB, false)]
+ [InlineData((UnixFileStatus)0xA124, false)]
+ [InlineData((UnixFileStatus)0xC092, false)]
+ [InlineData((UnixFileStatus)0xF049, false)]
+ public void IsBlockFileTest(UnixFileStatus mode, bool result) => Assert.Equal(result, mode.IsBlockFile());
+
+ [Theory]
+ [InlineData((UnixFileStatus)0x0FFF, false)]
+ [InlineData((UnixFileStatus)0x1FB6, false)]
+ [InlineData((UnixFileStatus)0x21FF, false)]
+ [InlineData((UnixFileStatus)0x41B6, false)]
+ [InlineData((UnixFileStatus)0x616D, false)]
+ [InlineData((UnixFileStatus)0x80DB, true)]
+ [InlineData((UnixFileStatus)0xA124, false)]
+ [InlineData((UnixFileStatus)0xC092, false)]
+ [InlineData((UnixFileStatus)0xF049, false)]
+ public void IsRegularFileTest(UnixFileStatus mode, bool result) => Assert.Equal(result, mode.IsRegularFile());
+
+ [Theory]
+ [InlineData((UnixFileStatus)0x0FFF, false)]
+ [InlineData((UnixFileStatus)0x1FB6, true)]
+ [InlineData((UnixFileStatus)0x21FF, false)]
+ [InlineData((UnixFileStatus)0x41B6, false)]
+ [InlineData((UnixFileStatus)0x616D, false)]
+ [InlineData((UnixFileStatus)0x80DB, false)]
+ [InlineData((UnixFileStatus)0xA124, false)]
+ [InlineData((UnixFileStatus)0xC092, false)]
+ [InlineData((UnixFileStatus)0xF049, false)]
+ public void IsFIFOTest(UnixFileStatus mode, bool result) => Assert.Equal(result, mode.IsFIFO());
+
+ [Theory]
+ [InlineData((UnixFileStatus)0x0FFF, false)]
+ [InlineData((UnixFileStatus)0x1FB6, false)]
+ [InlineData((UnixFileStatus)0x21FF, false)]
+ [InlineData((UnixFileStatus)0x41B6, false)]
+ [InlineData((UnixFileStatus)0x616D, false)]
+ [InlineData((UnixFileStatus)0x80DB, false)]
+ [InlineData((UnixFileStatus)0xA124, true)]
+ [InlineData((UnixFileStatus)0xC092, false)]
+ [InlineData((UnixFileStatus)0xF049, false)]
+ public void IsSymbolicLinkTest(UnixFileStatus mode, bool result) => Assert.Equal(result, mode.IsSymbolicLink());
+
+ [Theory]
+ [InlineData((UnixFileStatus)0x0FFF, false)]
+ [InlineData((UnixFileStatus)0x1FB6, false)]
+ [InlineData((UnixFileStatus)0x21FF, false)]
+ [InlineData((UnixFileStatus)0x41B6, false)]
+ [InlineData((UnixFileStatus)0x616D, false)]
+ [InlineData((UnixFileStatus)0x80DB, false)]
+ [InlineData((UnixFileStatus)0xA124, false)]
+ [InlineData((UnixFileStatus)0xC092, true)]
+ [InlineData((UnixFileStatus)0xF049, false)]
+ public void IsSocketTest(UnixFileStatus mode, bool result) => Assert.Equal(result, mode.IsSocket());
+
+ [Theory]
+ [InlineData((UnixFileStatus)0x0FFF, true)]
+ [InlineData((UnixFileStatus)0x1FB6, true)]
+ [InlineData((UnixFileStatus)0x21FF, true)]
+ [InlineData((UnixFileStatus)0x41B6, false)]
+ [InlineData((UnixFileStatus)0x616D, true)]
+ [InlineData((UnixFileStatus)0x80DB, false)]
+ [InlineData((UnixFileStatus)0xA124, false)]
+ [InlineData((UnixFileStatus)0xC092, true)]
+ [InlineData((UnixFileStatus)0xF049, true)]
+ public void IsOtherTest(UnixFileStatus mode, bool result) => Assert.Equal(result, mode.IsOther());
+
+ [Theory]
+ [InlineData((UnixFileStatus)0x0FFF, false)]
+ [InlineData((UnixFileStatus)0x1FB6, true)]
+ [InlineData((UnixFileStatus)0x21FF, true)]
+ [InlineData((UnixFileStatus)0x41B6, true)]
+ [InlineData((UnixFileStatus)0x616D, true)]
+ [InlineData((UnixFileStatus)0x80DB, true)]
+ [InlineData((UnixFileStatus)0xA124, true)]
+ [InlineData((UnixFileStatus)0xC092, true)]
+ [InlineData((UnixFileStatus)0xF049, true)]
+ public void IsTypeKnownTest(UnixFileStatus mode, bool result) => Assert.Equal(result, mode.IsTypeKnown());
+
+ [Theory]
+ [InlineData("\0rwsrwsrwt", (UnixFileStatus)0x0FFF)]
+ [InlineData("prwSrwSrwT", (UnixFileStatus)0x1FB6)]
+ [InlineData("crwxrwxrwx", (UnixFileStatus)0x21FF)]
+ [InlineData("drw-rw-rw-", (UnixFileStatus)0x41B6)]
+ [InlineData("br-xr-xr-x", (UnixFileStatus)0x616D)]
+ [InlineData("--wx-wx-wx", (UnixFileStatus)0x80DB)]
+ [InlineData("lr--r--r--", (UnixFileStatus)0xA124)]
+ [InlineData("s-w--w--w-", (UnixFileStatus)0xC092)]
+ [InlineData("?--x--x--x", (UnixFileStatus)0x0049)]
+ [InlineData("7777", (UnixFileStatus)0x0FFF)]
+ public void FromPermissionCodeTest(string code, UnixFileStatus mode) => Assert.Equal(mode, UnixFileStatusExtensions.FromPermissionCode(code));
+
+ [Theory]
+ [InlineData((UnixFileStatus)0x0FFF, "\0rwsrwsrwt")]
+ [InlineData((UnixFileStatus)0x1FB6, "prwSrwSrwT")]
+ [InlineData((UnixFileStatus)0x21FF, "crwxrwxrwx")]
+ [InlineData((UnixFileStatus)0x41B6, "drw-rw-rw-")]
+ [InlineData((UnixFileStatus)0x616D, "br-xr-xr-x")]
+ [InlineData((UnixFileStatus)0x80DB, "--wx-wx-wx")]
+ [InlineData((UnixFileStatus)0xA124, "lr--r--r--")]
+ [InlineData((UnixFileStatus)0xC092, "s-w--w--w-")]
+ [InlineData((UnixFileStatus)0xF049, "?--x--x--x")]
+ public void ToPermissionCodeTest(UnixFileStatus mode, string code) => Assert.Equal(code, mode.ToPermissionCode());
+ }
+}
diff --git a/AdvancedSharpAdbClient.Tests/Models/UnixFileStatusTests.cs b/AdvancedSharpAdbClient.Tests/Models/UnixFileStatusTests.cs
new file mode 100644
index 0000000..842853c
--- /dev/null
+++ b/AdvancedSharpAdbClient.Tests/Models/UnixFileStatusTests.cs
@@ -0,0 +1,31 @@
+using System.IO;
+using Xunit;
+
+namespace AdvancedSharpAdbClient.Models.Tests
+{
+ ///
+ /// Tests the class.
+ ///
+ public class UnixFileStatusTests
+ {
+ [Theory]
+ [InlineData(UnixFileMode.SetUser, UnixFileStatus.SetUser)]
+ [InlineData(UnixFileMode.SetGroup, UnixFileStatus.SetGroup)]
+ [InlineData(UnixFileMode.StickyBit, UnixFileStatus.StickyBit)]
+ [InlineData(UnixFileMode.UserRead, UnixFileStatus.UserRead)]
+ [InlineData(UnixFileMode.UserWrite, UnixFileStatus.UserWrite)]
+ [InlineData(UnixFileMode.UserExecute, UnixFileStatus.UserExecute)]
+ [InlineData(UnixFileMode.GroupRead, UnixFileStatus.GroupRead)]
+ [InlineData(UnixFileMode.GroupWrite, UnixFileStatus.GroupWrite)]
+ [InlineData(UnixFileMode.GroupExecute, UnixFileStatus.GroupExecute)]
+ [InlineData(UnixFileMode.OtherRead, UnixFileStatus.OtherRead)]
+ [InlineData(UnixFileMode.OtherWrite, UnixFileStatus.OtherWrite)]
+ [InlineData(UnixFileMode.OtherExecute, UnixFileStatus.OtherExecute)]
+ public void UnixFileModeTest(UnixFileMode mode, UnixFileStatus status)
+ {
+ Assert.Equal((int)mode, (int)status);
+ Assert.Equal(mode, (UnixFileMode)status);
+ Assert.Equal((UnixFileStatus)mode, status);
+ }
+ }
+}
diff --git a/AdvancedSharpAdbClient.Tests/SyncServiceTests.Async.cs b/AdvancedSharpAdbClient.Tests/SyncServiceTests.Async.cs
index e6a38d1..594ce9e 100644
--- a/AdvancedSharpAdbClient.Tests/SyncServiceTests.Async.cs
+++ b/AdvancedSharpAdbClient.Tests/SyncServiceTests.Async.cs
@@ -28,7 +28,8 @@ public async void StatAsyncTest()
return await service.StatAsync("/fstab.donatello");
});
- Assert.Equal(UnixFileType.Regular, value.FileType & UnixFileType.TypeMask);
+ Assert.Equal(UnixFileStatus.Regular, value.FileMode.GetFileType());
+ Assert.Equal((UnixFileStatus)416, value.FileMode.GetPermissions());
Assert.Equal(597, value.Size);
Assert.Equal(DateTimeExtensions.Epoch.ToLocalTime(), value.Time);
}
@@ -60,29 +61,29 @@ public async void GetListingAsyncTest()
Assert.Equal(4, value.Count);
- DateTime time = new DateTime(2015, 11, 3, 9, 47, 4, DateTimeKind.Utc).ToLocalTime();
+ DateTime time = new(2015, 11, 3, 9, 47, 4, DateTimeKind.Utc);
FileStatistics dir = value[0];
Assert.Equal(".", dir.Path);
- Assert.Equal((UnixFileType)16873, dir.FileType);
+ Assert.Equal((UnixFileStatus)16873, dir.FileMode);
Assert.Equal(0, dir.Size);
Assert.Equal(time, dir.Time);
FileStatistics parentDir = value[1];
Assert.Equal("..", parentDir.Path);
- Assert.Equal((UnixFileType)16877, parentDir.FileType);
+ Assert.Equal((UnixFileStatus)16877, parentDir.FileMode);
Assert.Equal(0, parentDir.Size);
Assert.Equal(time, parentDir.Time);
FileStatistics sdcard0 = value[2];
Assert.Equal("sdcard0", sdcard0.Path);
- Assert.Equal((UnixFileType)41471, sdcard0.FileType);
+ Assert.Equal((UnixFileStatus)41471, sdcard0.FileMode);
Assert.Equal(24, sdcard0.Size);
Assert.Equal(time, sdcard0.Time);
FileStatistics emulated = value[3];
Assert.Equal("emulated", emulated.Path);
- Assert.Equal((UnixFileType)16749, emulated.FileType);
+ Assert.Equal((UnixFileStatus)16749, emulated.FileMode);
Assert.Equal(0, emulated.Size);
Assert.Equal(time, emulated.Time);
}
@@ -114,29 +115,29 @@ public async void GetAsyncListingTest()
Assert.Equal(4, value.Count);
- DateTime time = new DateTime(2015, 11, 3, 9, 47, 4, DateTimeKind.Utc).ToLocalTime();
+ DateTime time = new(2015, 11, 3, 9, 47, 4, DateTimeKind.Utc);
FileStatistics dir = value[0];
Assert.Equal(".", dir.Path);
- Assert.Equal((UnixFileType)16873, dir.FileType);
+ Assert.Equal((UnixFileStatus)16873, dir.FileMode);
Assert.Equal(0, dir.Size);
Assert.Equal(time, dir.Time);
FileStatistics parentDir = value[1];
Assert.Equal("..", parentDir.Path);
- Assert.Equal((UnixFileType)16877, parentDir.FileType);
+ Assert.Equal((UnixFileStatus)16877, parentDir.FileMode);
Assert.Equal(0, parentDir.Size);
Assert.Equal(time, parentDir.Time);
FileStatistics sdcard0 = value[2];
Assert.Equal("sdcard0", sdcard0.Path);
- Assert.Equal((UnixFileType)41471, sdcard0.FileType);
+ Assert.Equal((UnixFileStatus)41471, sdcard0.FileMode);
Assert.Equal(24, sdcard0.Size);
Assert.Equal(time, sdcard0.Time);
FileStatistics emulated = value[3];
Assert.Equal("emulated", emulated.Path);
- Assert.Equal((UnixFileType)16749, emulated.FileType);
+ Assert.Equal((UnixFileStatus)16749, emulated.FileMode);
Assert.Equal(0, emulated.Size);
Assert.Equal(time, emulated.Time);
}
@@ -177,7 +178,7 @@ await RunTestAsync(
}
///
- /// Tests the method.
+ /// Tests the method.
///
[Fact]
public async void PushAsyncTest()
@@ -205,7 +206,7 @@ await RunTestAsync(
async () =>
{
using SyncService service = new(Socket, Device);
- await service.PushAsync(stream, "/sdcard/test", 0644, new DateTime(2015, 11, 2, 23, 0, 0, DateTimeKind.Utc), null);
+ await service.PushAsync(stream, "/sdcard/test", UnixFileStatus.StickyBit | UnixFileStatus.UserWrite | UnixFileStatus.OtherRead, new DateTime(2015, 11, 2, 23, 0, 0, DateTimeKind.Utc), null);
});
}
@@ -247,7 +248,7 @@ await RunTestAsync(
}
///
- /// Tests the method.
+ /// Tests the method.
///
[Fact]
public async void PushWinRTAsyncTest()
@@ -276,7 +277,7 @@ await RunTestAsync(
async () =>
{
using SyncService service = new(Socket, Device);
- await service.PushAsync(stream, "/sdcard/test", 0644, new DateTime(2015, 11, 2, 23, 0, 0, DateTimeKind.Utc), null);
+ await service.PushAsync(stream, "/sdcard/test", (UnixFileStatus)644, new DateTime(2015, 11, 2, 23, 0, 0, DateTimeKind.Utc), null);
});
}
#endif
diff --git a/AdvancedSharpAdbClient.Tests/SyncServiceTests.cs b/AdvancedSharpAdbClient.Tests/SyncServiceTests.cs
index 88a4a15..170aba8 100644
--- a/AdvancedSharpAdbClient.Tests/SyncServiceTests.cs
+++ b/AdvancedSharpAdbClient.Tests/SyncServiceTests.cs
@@ -38,7 +38,8 @@ public void StatTest()
return service.Stat("/fstab.donatello");
});
- Assert.Equal(UnixFileType.Regular, value.FileType & UnixFileType.TypeMask);
+ Assert.Equal(UnixFileStatus.Regular, value.FileMode.GetFileType());
+ Assert.Equal((UnixFileStatus)416, value.FileMode.GetPermissions());
Assert.Equal(597, value.Size);
Assert.Equal(DateTimeExtensions.Epoch.ToLocalTime(), value.Time);
}
@@ -70,29 +71,29 @@ public void GetListingTest()
Assert.Equal(4, value.Length);
- DateTime time = new DateTime(2015, 11, 3, 9, 47, 4, DateTimeKind.Utc).ToLocalTime();
+ DateTime time = new(2015, 11, 3, 9, 47, 4, DateTimeKind.Utc);
FileStatistics dir = value[0];
Assert.Equal(".", dir.Path);
- Assert.Equal((UnixFileType)16873, dir.FileType);
+ Assert.Equal((UnixFileStatus)16873, dir.FileMode);
Assert.Equal(0, dir.Size);
Assert.Equal(time, dir.Time);
FileStatistics parentDir = value[1];
Assert.Equal("..", parentDir.Path);
- Assert.Equal((UnixFileType)16877, parentDir.FileType);
+ Assert.Equal((UnixFileStatus)16877, parentDir.FileMode);
Assert.Equal(0, parentDir.Size);
Assert.Equal(time, parentDir.Time);
FileStatistics sdcard0 = value[2];
Assert.Equal("sdcard0", sdcard0.Path);
- Assert.Equal((UnixFileType)41471, sdcard0.FileType);
+ Assert.Equal((UnixFileStatus)41471, sdcard0.FileMode);
Assert.Equal(24, sdcard0.Size);
Assert.Equal(time, sdcard0.Time);
FileStatistics emulated = value[3];
Assert.Equal("emulated", emulated.Path);
- Assert.Equal((UnixFileType)16749, emulated.FileType);
+ Assert.Equal((UnixFileStatus)16749, emulated.FileMode);
Assert.Equal(0, emulated.Size);
Assert.Equal(time, emulated.Time);
}
@@ -133,7 +134,7 @@ public void PullTest()
}
///
- /// Tests the method.
+ /// Tests the method.
///
[Fact]
public void PushTest()
@@ -161,7 +162,7 @@ .. BitConverter.GetBytes(content.Length),
() =>
{
using SyncService service = new(Socket, Device);
- service.Push(stream, "/sdcard/test", 0644, new DateTime(2015, 11, 2, 23, 0, 0, DateTimeKind.Utc));
+ service.Push(stream, "/sdcard/test", (UnixFileStatus)644, new DateTime(2015, 11, 2, 23, 0, 0, DateTimeKind.Utc));
});
}
}
diff --git a/AdvancedSharpAdbClient/AdbSocket.Async.cs b/AdvancedSharpAdbClient/AdbSocket.Async.cs
index 90cc8a8..99ac80b 100644
--- a/AdvancedSharpAdbClient/AdbSocket.Async.cs
+++ b/AdvancedSharpAdbClient/AdbSocket.Async.cs
@@ -79,8 +79,8 @@ public virtual async Task SendAsync(byte[] data, int offset, int length, Cancell
}
///
- public Task SendSyncRequestAsync(SyncCommand command, string path, int permissions, CancellationToken cancellationToken = default) =>
- SendSyncRequestAsync(command, $"{path},{permissions}", cancellationToken);
+ public Task SendSyncRequestAsync(SyncCommand command, string path, UnixFileStatus permission, CancellationToken cancellationToken = default) =>
+ SendSyncRequestAsync(command, $"{path},{(int)permission.GetPermissions()}", cancellationToken);
///
public async Task SendSyncRequestAsync(SyncCommand command, string path, CancellationToken cancellationToken = default)
diff --git a/AdvancedSharpAdbClient/AdbSocket.cs b/AdvancedSharpAdbClient/AdbSocket.cs
index 056717b..f997654 100644
--- a/AdvancedSharpAdbClient/AdbSocket.cs
+++ b/AdvancedSharpAdbClient/AdbSocket.cs
@@ -154,8 +154,8 @@ public virtual void Send(byte[] data, int offset, int length)
}
///
- public void SendSyncRequest(SyncCommand command, string path, int permissions) =>
- SendSyncRequest(command, $"{path},{permissions}");
+ public void SendSyncRequest(SyncCommand command, string path, UnixFileStatus permission) =>
+ SendSyncRequest(command, $"{path},{(int)permission.GetPermissions()}");
///
public void SendSyncRequest(SyncCommand command, string path)
diff --git a/AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj b/AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj
index 84d1894..936dd23 100644
--- a/AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj
+++ b/AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj
@@ -103,7 +103,7 @@
-
+
diff --git a/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.Async.cs b/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.Async.cs
index 4b72885..0930074 100644
--- a/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.Async.cs
+++ b/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.Async.cs
@@ -221,19 +221,18 @@ public static async Task PullAsync(this IAdbClient client, DeviceData device,
/// The device on which to put the file.
/// The path, on the device, to which to push the file.
/// A that contains the contents of the file.
- /// The permission octet that contains the permissions of the newly created file on the device.
+ /// The that contains the permissions of the newly created file on the device.
/// The time at which the file was last modified.
/// An optional parameter which, when specified, returns progress notifications. The progress is reported as a value between 0 and 100, representing the percentage of the file which has been transferred.
/// A that can be used to cancel the task.
/// A which represents the asynchronous operation.
- /// The should coverts to a decimal number. For example, 644 should be 420 in decimal, &O644 in VB.NET and 0o644 in F# and Python.
public static async Task PushAsync(this IAdbClient client, DeviceData device,
- string remotePath, Stream stream, int permissions, DateTimeOffset timestamp,
+ string remotePath, Stream stream, UnixFileStatus permission, DateTimeOffset timestamp,
Action? callback = null,
CancellationToken cancellationToken = default)
{
using ISyncService service = Factories.SyncServiceFactory(client, device);
- await service.PushAsync(stream, remotePath, permissions, timestamp, callback, cancellationToken).ConfigureAwait(false);
+ await service.PushAsync(stream, remotePath, permission, timestamp, callback, cancellationToken).ConfigureAwait(false);
}
///
@@ -406,19 +405,18 @@ public static async Task PullAsync(this IAdbClient client, DeviceData device,
/// The device on which to put the file.
/// The path, on the device, to which to push the file.
/// A that contains the contents of the file.
- /// The permission octet that contains the permissions of the newly created file on the device.
+ /// The that contains the permissions of the newly created file on the device.
/// The time at which the file was last modified.
/// An optional parameter which, when specified, returns progress notifications. The progress is reported as a value between 0 and 100, representing the percentage of the file which has been transferred.
/// A that can be used to cancel the task.
/// A which represents the asynchronous operation.
- /// The should coverts to a decimal number. For example, 644 should be 420 in decimal, &O644 in VB.NET and 0o644 in F# and Python.
public static async Task PushAsync(this IAdbClient client, DeviceData device,
- string remotePath, Stream stream, int permissions, DateTimeOffset timestamp,
+ string remotePath, Stream stream, UnixFileStatus permission, DateTimeOffset timestamp,
IProgress? progress,
CancellationToken cancellationToken = default)
{
using ISyncService service = Factories.SyncServiceFactory(client, device);
- await service.PushAsync(stream, remotePath, permissions, timestamp, progress.AsAction(), cancellationToken).ConfigureAwait(false);
+ await service.PushAsync(stream, remotePath, permission, timestamp, progress.AsAction(), cancellationToken).ConfigureAwait(false);
}
///
@@ -493,7 +491,7 @@ public static async Task PushAsync(this IAdbClient client, DeviceData device,
CancellationToken cancellationToken = default)
{
using ISyncService service = Factories.SyncServiceFactory(client, device);
- await service.PushAsync(stream, remotePath, (int)permission, timestamp, callback, cancellationToken).ConfigureAwait(false);
+ await service.PushAsync(stream, remotePath, (UnixFileStatus)permission, timestamp, callback, cancellationToken).ConfigureAwait(false);
}
///
@@ -514,7 +512,7 @@ public static async Task PushAsync(this IAdbClient client, DeviceData device,
CancellationToken cancellationToken = default)
{
using ISyncService service = Factories.SyncServiceFactory(client, device);
- await service.PushAsync(stream, remotePath, (int)permission, timestamp, progress.AsAction(), cancellationToken).ConfigureAwait(false);
+ await service.PushAsync(stream, remotePath, (UnixFileStatus)permission, timestamp, progress.AsAction(), cancellationToken).ConfigureAwait(false);
}
#endif
#endif
diff --git a/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.cs b/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.cs
index da21372..9a0bf86 100644
--- a/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.cs
+++ b/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.cs
@@ -195,18 +195,18 @@ public static void Pull(this IAdbClient client, DeviceData device,
/// The device on which to put the file.
/// The path, on the device, to which to push the file.
/// A that contains the contents of the file.
- /// The permission octet that contains the permissions of the newly created file on the device.
+ /// The that contains the permissions of the newly created file on the device.
/// The time at which the file was last modified.
/// An optional parameter which, when specified, returns progress notifications. The progress is reported as a value between 0 and 100, representing the percentage of the file which has been transferred.
/// A that can be used to cancel the task.
- /// The should coverts to a decimal number. For example, 644 should be 420 in decimal, &O644 in VB.NET and 0o644 in F# and Python.
+ /// The should coverts to a decimal number. For example, 644 should be 420 in decimal, &O644 in VB.NET and 0o644 in F# and Python.
public static void Push(this IAdbClient client, DeviceData device,
- string remotePath, Stream stream, int permissions, DateTimeOffset timestamp,
+ string remotePath, Stream stream, UnixFileStatus permission, DateTimeOffset timestamp,
Action? callback = null,
in bool isCancelled = false)
{
using ISyncService service = Factories.SyncServiceFactory(client, device);
- service.Push(stream, remotePath, permissions, timestamp, callback, in isCancelled);
+ service.Push(stream, remotePath, permission, timestamp, callback, in isCancelled);
}
///
@@ -351,18 +351,18 @@ public static void Pull(this IAdbClient client, DeviceData device,
/// The device on which to put the file.
/// The path, on the device, to which to push the file.
/// A that contains the contents of the file.
- /// The permission octet that contains the permissions of the newly created file on the device.
+ /// The that contains the permissions of the newly created file on the device.
/// The time at which the file was last modified.
/// An optional parameter which, when specified, returns progress notifications. The progress is reported as a value between 0 and 100, representing the percentage of the file which has been transferred.
/// A that can be used to cancel the task.
- /// The should coverts to a decimal number. For example, 644 should be 420 in decimal, &O644 in VB.NET and 0o644 in F# and Python.
+ /// The should coverts to a decimal number. For example, 644 should be 420 in decimal, &O644 in VB.NET and 0o644 in F# and Python.
public static void Push(this IAdbClient client, DeviceData device,
- string remotePath, Stream stream, int permissions, DateTimeOffset timestamp,
+ string remotePath, Stream stream, UnixFileStatus permission, DateTimeOffset timestamp,
IProgress? progress = null,
in bool isCancelled = false)
{
using ISyncService service = Factories.SyncServiceFactory(client, device);
- service.Push(stream, remotePath, permissions, timestamp, progress.AsAction(), in isCancelled);
+ service.Push(stream, remotePath, permission, timestamp, progress.AsAction(), in isCancelled);
}
///
@@ -430,7 +430,7 @@ public static void Push(this IAdbClient client, DeviceData device,
in bool isCancelled = false)
{
using ISyncService service = Factories.SyncServiceFactory(client, device);
- service.Push(stream, remotePath, (int)permission, timestamp, callback, in isCancelled);
+ service.Push(stream, remotePath, (UnixFileStatus)permission, timestamp, callback, in isCancelled);
}
///
@@ -450,7 +450,7 @@ public static void Push(this IAdbClient client, DeviceData device,
in bool isCancelled = false)
{
using ISyncService service = Factories.SyncServiceFactory(client, device);
- service.Push(stream, remotePath, (int)permission, timestamp, progress.AsAction(), in isCancelled);
+ service.Push(stream, remotePath, (UnixFileStatus)permission, timestamp, progress.AsAction(), in isCancelled);
}
#endif
#endif
diff --git a/AdvancedSharpAdbClient/DeviceCommands/PackageManager.Async.cs b/AdvancedSharpAdbClient/DeviceCommands/PackageManager.Async.cs
index 02cde32..9da7d99 100644
--- a/AdvancedSharpAdbClient/DeviceCommands/PackageManager.Async.cs
+++ b/AdvancedSharpAdbClient/DeviceCommands/PackageManager.Async.cs
@@ -589,7 +589,7 @@ protected virtual async Task SyncPackageToDeviceAsync(string localFilePa
Action? progress = callback == null ? null : args => callback.Invoke(localFilePath, args);
// As C# can't use octal, the octal literal 666 (rw-Permission) is here converted to decimal (438)
- await sync.PushAsync(stream, remoteFilePath, 438, File.GetLastWriteTime(localFilePath), null, cancellationToken).ConfigureAwait(false);
+ await sync.PushAsync(stream, remoteFilePath, UnixFileStatus.DefaultFileMode, File.GetLastWriteTime(localFilePath), null, cancellationToken).ConfigureAwait(false);
}
return remoteFilePath;
diff --git a/AdvancedSharpAdbClient/DeviceCommands/PackageManager.cs b/AdvancedSharpAdbClient/DeviceCommands/PackageManager.cs
index 1a46af0..52427fe 100644
--- a/AdvancedSharpAdbClient/DeviceCommands/PackageManager.cs
+++ b/AdvancedSharpAdbClient/DeviceCommands/PackageManager.cs
@@ -633,7 +633,7 @@ protected virtual string SyncPackageToDevice(string localFilePath, Action? progress = callback == null ? null : args => callback.Invoke(localFilePath, args);
// As C# can't use octal, the octal literal 666 (rw-Permission) is here converted to decimal (438)
- sync.Push(stream, remoteFilePath, 438, File.GetLastWriteTime(localFilePath), progress, false);
+ sync.Push(stream, remoteFilePath, UnixFileStatus.DefaultFileMode, File.GetLastWriteTime(localFilePath), progress, false);
}
return remoteFilePath;
diff --git a/AdvancedSharpAdbClient/Extensions/EnumerableBuilder.cs b/AdvancedSharpAdbClient/Extensions/EnumerableBuilder.cs
index 73665a8..dff31a4 100644
--- a/AdvancedSharpAdbClient/Extensions/EnumerableBuilder.cs
+++ b/AdvancedSharpAdbClient/Extensions/EnumerableBuilder.cs
@@ -50,13 +50,21 @@ public static FileStatistics FileStatisticsCreator(ReadOnlySpan values)
int index = 0;
return new FileStatistics
{
- FileType = (UnixFileType)ReadInt32(values),
+ FileMode = (UnixFileStatus)ReadInt32(values),
Size = ReadInt32(values),
Time = DateTimeExtensions.FromUnixTimeSeconds(ReadInt32(values))
};
int ReadInt32(in ReadOnlySpan data) => data[index++] | (data[index++] << 8) | (data[index++] << 16) | (data[index++] << 24);
}
+ ///
+ /// Build a enum.
+ ///
+ /// The data that feeds the struct.
+ /// A new instance of struct.
+ public static UnixFileStatus UnixFileStatusCreator(ReadOnlySpan values) =>
+ (UnixFileStatus)(values[0] | (values[1] << 8) | (values[2] << 16) | (values[3] << 24));
+
///
/// Build a class.
///
diff --git a/AdvancedSharpAdbClient/Extensions/LoggerExtensions.cs b/AdvancedSharpAdbClient/Extensions/LoggerExtensions.cs
index 14566e7..0a39c61 100644
--- a/AdvancedSharpAdbClient/Extensions/LoggerExtensions.cs
+++ b/AdvancedSharpAdbClient/Extensions/LoggerExtensions.cs
@@ -4,7 +4,7 @@
using System;
-namespace AdvancedSharpAdbClient
+namespace AdvancedSharpAdbClient.Logs
{
///
/// ILogger extension methods for common scenarios.
diff --git a/AdvancedSharpAdbClient/Extensions/SyncCommandConverter.cs b/AdvancedSharpAdbClient/Extensions/SyncCommandConverter.cs
index 21e4c11..7660cde 100644
--- a/AdvancedSharpAdbClient/Extensions/SyncCommandConverter.cs
+++ b/AdvancedSharpAdbClient/Extensions/SyncCommandConverter.cs
@@ -5,7 +5,7 @@
using System;
using System.Collections.Generic;
-namespace AdvancedSharpAdbClient
+namespace AdvancedSharpAdbClient.Models
{
///
/// Converts values to their binary representation and vice versa.
diff --git a/AdvancedSharpAdbClient/Extensions/SyncServiceExtensions.Async.cs b/AdvancedSharpAdbClient/Extensions/SyncServiceExtensions.Async.cs
index 6a9ee27..532b876 100644
--- a/AdvancedSharpAdbClient/Extensions/SyncServiceExtensions.Async.cs
+++ b/AdvancedSharpAdbClient/Extensions/SyncServiceExtensions.Async.cs
@@ -17,13 +17,12 @@ public static partial class SyncServiceExtensions
/// An instance of a class that implements the interface.
/// A that contains the contents of the file.
/// The path, on the device, to which to push the file.
- /// The permission octet that contains the permissions of the newly created file on the device.
+ /// The that contains the permissions of the newly created file on the device.
/// The time at which the file was last modified.
/// An optional parameter which, when specified, returns progress notifications. The progress is reported as , representing the state of the file which has been transferred.
/// A that can be used to cancel the task.
/// A which represents the asynchronous operation.
- /// The should coverts to a decimal number. For example, 644 should be 420 in decimal, &O644 in VB.NET and 0o644 in F# and Python.
- public static Task PushAsync(this ISyncService service, Stream stream, string remotePath, int permissions, DateTimeOffset timestamp, IProgress? progress = null, CancellationToken cancellationToken = default) =>
+ public static Task PushAsync(this ISyncService service, Stream stream, string remotePath, UnixFileStatus permissions, DateTimeOffset timestamp, IProgress? progress = null, CancellationToken cancellationToken = default) =>
service.PushAsync(stream, remotePath, permissions, timestamp, progress.AsAction(), cancellationToken);
///
@@ -45,13 +44,12 @@ public static Task PullAsync(this ISyncService service, string remotePath, Strea
/// An instance of a class that implements the interface.
/// A that contains the contents of the file.
/// The path, on the device, to which to push the file.
- /// The permission octet that contains the permissions of the newly created file on the device.
+ /// The that contains the permissions of the newly created file on the device.
/// The time at which the file was last modified.
/// An optional parameter which, when specified, returns progress notifications. The progress is reported as , representing the state of the file which has been transferred.
/// A that can be used to cancel the task.
/// A which represents the asynchronous operation.
- /// The should coverts to a decimal number. For example, 644 should be 420 in decimal, &O644 in VB.NET and 0o644 in F# and Python.
- public static Task PushAsync(this ISyncService.IWinRT service, IInputStream stream, string remotePath, int permissions, DateTimeOffset timestamp, IProgress? progress = null, CancellationToken cancellationToken = default) =>
+ public static Task PushAsync(this ISyncService.IWinRT service, IInputStream stream, string remotePath, UnixFileStatus permissions, DateTimeOffset timestamp, IProgress? progress = null, CancellationToken cancellationToken = default) =>
service.PushAsync(stream, remotePath, permissions, timestamp, progress.AsAction(), cancellationToken);
///
@@ -74,13 +72,13 @@ public static Task PullAsync(this ISyncService.IWinRT service, string remotePath
/// An instance of a class that implements the interface.
/// A that contains the contents of the file.
/// The path, on the device, to which to push the file.
- /// The that contains the permissions of the newly created file on the device.
+ /// The that contains the permissions of the newly created file on the device.
/// The time at which the file was last modified.
/// An optional parameter which, when specified, returns progress notifications. The progress is reported as , representing the state of the file which has been transferred.
/// A that can be used to cancel the task.
/// A which represents the asynchronous operation.
- public static Task PushAsync(this ISyncService service, Stream stream, string remotePath, UnixFileMode permission, DateTimeOffset timestamp, Action? callback = null, CancellationToken cancellationToken = default) =>
- service.PushAsync(stream, remotePath, (int)permission, timestamp, callback, cancellationToken);
+ public static Task PushAsync(this ISyncService service, Stream stream, string remotePath, UnixFileMode permissions, DateTimeOffset timestamp, Action? callback = null, CancellationToken cancellationToken = default) =>
+ service.PushAsync(stream, remotePath, (UnixFileStatus)permissions, timestamp, callback, cancellationToken);
///
/// Asynchronously pushes (uploads) a file to the remote device.
@@ -88,13 +86,13 @@ public static Task PushAsync(this ISyncService service, Stream stream, string re
/// An instance of a class that implements the interface.
/// A that contains the contents of the file.
/// The path, on the device, to which to push the file.
- /// The that contains the permissions of the newly created file on the device.
+ /// The that contains the permissions of the newly created file on the device.
/// The time at which the file was last modified.
/// An optional parameter which, when specified, returns progress notifications. The progress is reported as , representing the state of the file which has been transferred.
/// A that can be used to cancel the task.
/// A which represents the asynchronous operation.
- public static Task PushAsync(this ISyncService service, Stream stream, string remotePath, UnixFileMode permission, DateTimeOffset timestamp, IProgress? progress, CancellationToken cancellationToken = default) =>
- service.PushAsync(stream, remotePath, (int)permission, timestamp, progress.AsAction(), cancellationToken);
+ public static Task PushAsync(this ISyncService service, Stream stream, string remotePath, UnixFileMode permissions, DateTimeOffset timestamp, IProgress? progress, CancellationToken cancellationToken = default) =>
+ service.PushAsync(stream, remotePath, (UnixFileStatus)permissions, timestamp, progress.AsAction(), cancellationToken);
#if WINDOWS10_0_17763_0_OR_GREATER
///
@@ -103,13 +101,13 @@ public static Task PushAsync(this ISyncService service, Stream stream, string re
/// An instance of a class that implements the interface.
/// A that contains the contents of the file.
/// The path, on the device, to which to push the file.
- /// The that contains the permissions of the newly created file on the device.
+ /// The that contains the permissions of the newly created file on the device.
/// The time at which the file was last modified.
/// An optional parameter which, when specified, returns progress notifications. The progress is reported as , representing the state of the file which has been transferred.
/// A that can be used to cancel the task.
/// A which represents the asynchronous operation.
- public static Task PushAsync(this ISyncService.IWinRT service, IInputStream stream, string remotePath, UnixFileMode permission, DateTimeOffset timestamp, Action? callback = null, CancellationToken cancellationToken = default) =>
- service.PushAsync(stream, remotePath, (int)permission, timestamp, callback, cancellationToken);
+ public static Task PushAsync(this ISyncService.IWinRT service, IInputStream stream, string remotePath, UnixFileMode permissions, DateTimeOffset timestamp, Action? callback = null, CancellationToken cancellationToken = default) =>
+ service.PushAsync(stream, remotePath, (UnixFileStatus)permissions, timestamp, callback, cancellationToken);
///
/// Asynchronously pushes (uploads) a file to the remote device.
@@ -117,13 +115,13 @@ public static Task PushAsync(this ISyncService.IWinRT service, IInputStream stre
/// An instance of a class that implements the interface.
/// A that contains the contents of the file.
/// The path, on the device, to which to push the file.
- /// The that contains the permissions of the newly created file on the device.
+ /// The that contains the permissions of the newly created file on the device.
/// The time at which the file was last modified.
/// An optional parameter which, when specified, returns progress notifications. The progress is reported as , representing the state of the file which has been transferred.
/// A that can be used to cancel the task.
/// A which represents the asynchronous operation.
- public static Task PushAsync(this ISyncService.IWinRT service, IInputStream stream, string remotePath, UnixFileMode permission, DateTimeOffset timestamp, IProgress? progress, CancellationToken cancellationToken = default) =>
- service.PushAsync(stream, remotePath, (int)permission, timestamp, progress.AsAction(), cancellationToken);
+ public static Task PushAsync(this ISyncService.IWinRT service, IInputStream stream, string remotePath, UnixFileMode permissions, DateTimeOffset timestamp, IProgress? progress, CancellationToken cancellationToken = default) =>
+ service.PushAsync(stream, remotePath, (UnixFileStatus)permissions, timestamp, progress.AsAction(), cancellationToken);
#endif
#endif
}
diff --git a/AdvancedSharpAdbClient/Extensions/SyncServiceExtensions.cs b/AdvancedSharpAdbClient/Extensions/SyncServiceExtensions.cs
index e1e7d9b..c9b55e4 100644
--- a/AdvancedSharpAdbClient/Extensions/SyncServiceExtensions.cs
+++ b/AdvancedSharpAdbClient/Extensions/SyncServiceExtensions.cs
@@ -19,12 +19,11 @@ public static partial class SyncServiceExtensions
/// An instance of a class that implements the interface.
/// A that contains the contents of the file.
/// The path, on the device, to which to push the file.
- /// The permission octet that contains the permissions of the newly created file on the device.
+ /// The that contains the permissions of the newly created file on the device.
/// The time at which the file was last modified.
/// An optional parameter which, when specified, returns progress notifications. The progress is reported as , representing the state of the file which has been transferred.
/// A that can be used to cancel the task.
- /// The should coverts to a decimal number. For example, 644 should be 420 in decimal, &O644 in VB.NET and 0o644 in F# and Python.
- public static void Push(this ISyncService service, Stream stream, string remotePath, int permissions, DateTimeOffset timestamp, IProgress? progress = null, in bool isCancelled = false) =>
+ public static void Push(this ISyncService service, Stream stream, string remotePath, UnixFileStatus permissions, DateTimeOffset timestamp, IProgress? progress = null, in bool isCancelled = false) =>
service.Push(stream, remotePath, permissions, timestamp, progress.AsAction(), isCancelled);
///
@@ -50,7 +49,7 @@ public static void Pull(this ISyncService service, string remotePath, Stream str
/// An optional parameter which, when specified, returns progress notifications. The progress is reported as , representing the state of the file which has been transferred.
/// A that can be used to cancel the task.
public static void Push(this ISyncService service, Stream stream, string remotePath, UnixFileMode permissions, DateTimeOffset timestamp, Action? callback = null, in bool isCancelled = false) =>
- service.Push(stream, remotePath, (int)permissions, timestamp, callback, isCancelled);
+ service.Push(stream, remotePath, (UnixFileStatus)permissions, timestamp, callback, isCancelled);
///
/// Pushes (uploads) a file to the remote device.
@@ -63,7 +62,7 @@ public static void Push(this ISyncService service, Stream stream, string remoteP
/// An optional parameter which, when specified, returns progress notifications. The progress is reported as , representing the state of the file which has been transferred.
/// A that can be used to cancel the task.
public static void Push(this ISyncService service, Stream stream, string remotePath, UnixFileMode permissions, DateTimeOffset timestamp, IProgress? progress, in bool isCancelled = false) =>
- service.Push(stream, remotePath, (int)permissions, timestamp, progress.AsAction(), isCancelled);
+ service.Push(stream, remotePath, (UnixFileStatus)permissions, timestamp, progress.AsAction(), isCancelled);
#endif
}
}
diff --git a/AdvancedSharpAdbClient/Extensions/UnixFileStatusExtensions.cs b/AdvancedSharpAdbClient/Extensions/UnixFileStatusExtensions.cs
new file mode 100644
index 0000000..5797dbc
--- /dev/null
+++ b/AdvancedSharpAdbClient/Extensions/UnixFileStatusExtensions.cs
@@ -0,0 +1,268 @@
+//
+// Copyright (c) The Android Open Source Project, Ryan Conrad, Quamotion, yungd1plomat, wherewhere. All rights reserved.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace AdvancedSharpAdbClient.Models
+{
+ ///
+ /// Provides extension methods for the enum. Provides overloads for commonly used functions.
+ ///
+ public static class UnixFileStatusExtensions
+ {
+ ///
+ /// Gets the type of the given file status.
+ ///
+ /// File status to process.
+ /// The type of the file status.
+ public static UnixFileStatus GetFileType(this UnixFileStatus mode) => mode & UnixFileStatus.TypeMask;
+
+ ///
+ /// Gets the permissions of the given file status.
+ ///
+ /// File status to process.
+ /// The permissions of the given file status.
+ public static UnixFileStatus GetPermissions(this UnixFileStatus mode) => mode & UnixFileStatus.AllPermissions;
+
+ ///
+ /// Gets the access permissions of the given file status.
+ ///
+ /// File status to process.
+ /// The access permissions of the given file status.
+ public static UnixFileStatus GetAccessPermissions(this UnixFileStatus mode) => mode & UnixFileStatus.AccessPermissions;
+
+ ///
+ /// Checks if the given file status corresponds to a directory, as if determined by .
+ ///
+ /// File status to check.
+ /// if the type indicated refers to a directory, otherwise .
+ public static bool IsDirectory(this UnixFileStatus mode) => mode.GetFileType() == UnixFileStatus.Directory;
+
+ ///
+ /// Checks if the given file status or path corresponds to a character special file, as if determined by .
+ /// Examples of character special files are character devices such as /dev/null, /dev/tty, /dev/audio, or /dev/nvram on Linux.
+ ///
+ /// File status to check.
+ /// if the type indicated refers to a character device, otherwise .
+ public static bool IsCharacterFile(this UnixFileStatus mode) => mode.GetFileType() == UnixFileStatus.Character;
+
+ ///
+ /// Checks if the given file status corresponds to a block special file, as if determined by .
+ /// Examples of block special files are block devices such as /dev/sda or /dev/loop0 on Linux.
+ ///
+ /// File status to check.
+ /// if the type indicated refers to a block device, otherwise .
+ public static bool IsBlockFile(this UnixFileStatus mode) => mode.GetFileType() == UnixFileStatus.Block;
+
+ ///
+ /// Checks if the given file status corresponds to a regular file, as if determined by .
+ ///
+ /// File status to check.
+ /// if the type indicated by refers to a regular file, otherwise .
+ public static bool IsRegularFile(this UnixFileStatus mode) => mode.GetFileType() == UnixFileStatus.Regular;
+
+ ///
+ /// Checks if the given file status corresponds to a FIFO or pipe file as if determined by .
+ ///
+ /// File status to check.
+ /// if the type indicated refers to a FIFO pipe, otherwise .
+ public static bool IsFIFO(this UnixFileStatus mode) => mode.GetFileType() == UnixFileStatus.FIFO;
+
+ ///
+ /// Checks if the given file status corresponds to a symbolic link, as if determined by .
+ ///
+ /// File status to check.
+ /// if the type indicated refers to a symbolic link, otherwise .
+ public static bool IsSymbolicLink(this UnixFileStatus mode) => mode.GetFileType() == UnixFileStatus.SymbolicLink;
+
+ ///
+ /// Checks if the given file status or path corresponds to a named IPC socket, as if determined by .
+ ///
+ /// File status to check.
+ /// if the type indicated refers to a named socket, otherwise .
+ public static bool IsSocket(this UnixFileStatus mode) => mode.GetFileType() == UnixFileStatus.Socket;
+
+ ///
+ /// Checks if the given file status corresponds to a file of type other type. That is, the file exists, but is neither regular file, nor directory nor a symlink.
+ ///
+ /// File status to check.
+ /// if the type indicated refers to a file that is not regular file, directory, or a symlink, otherwise .
+ public static bool IsOther(this UnixFileStatus mode) => mode.GetFileType() is not (UnixFileStatus.Regular or UnixFileStatus.Directory or UnixFileStatus.SymbolicLink);
+
+ ///
+ /// Checks if the given file type is known, equivalent to mode.GetFileType() != .
+ ///
+ /// File type to check.
+ /// if the given file type is a known file type, otherwise .
+ public static bool IsTypeKnown(this UnixFileStatus mode) => mode.GetFileType() != UnixFileStatus.None;
+
+ ///
+ /// Parses a Unix permission code into a .
+ ///
+ /// The permission code to parse.
+ /// A representing the parsed permission code.
+ public static UnixFileStatus FromPermissionCode(string code)
+ {
+ ExceptionExtensions.ThrowIfNull(code);
+
+ if (code.Length is not (9 or 10))
+ {
+ try
+ {
+ return (UnixFileStatus)Convert.ToInt32(code, 8);
+ }
+ catch
+ {
+ throw new ArgumentOutOfRangeException(nameof(code), $"The length of {nameof(code)} should be 9 or 10, but it is {code.Length}.");
+ }
+ }
+
+ UnixFileStatus mode = UnixFileStatus.None;
+ int index = code.Length;
+
+ mode |= code[--index] switch
+ {
+ 'x' => UnixFileStatus.OtherExecute,
+ 't' => UnixFileStatus.StickyBit | UnixFileStatus.OtherExecute,
+ 'T' => UnixFileStatus.StickyBit,
+ '-' => UnixFileStatus.None,
+ _ => throw new ArgumentOutOfRangeException(nameof(code), $"The char of index {index} should be 'x', 't', 'T' or '-', but it is {code[index]}.")
+ };
+ mode |= code[--index] switch
+ {
+ 'w' => UnixFileStatus.OtherWrite,
+ '-' => UnixFileStatus.None,
+ _ => throw new ArgumentOutOfRangeException(nameof(code), $"The char of index {index} should be 'w' or '-', but it is {code[index]}.")
+ };
+ mode |= code[--index] switch
+ {
+ 'r' => UnixFileStatus.OtherRead,
+ '-' => UnixFileStatus.None,
+ _ => throw new ArgumentOutOfRangeException(nameof(code), $"The char of index {index} should be 'r' or '-', but it is {code[index]}.")
+ };
+
+ mode |= code[--index] switch
+ {
+ 'x' => UnixFileStatus.GroupExecute,
+ 's' => UnixFileStatus.SetGroup | UnixFileStatus.GroupExecute,
+ 'S' => UnixFileStatus.SetGroup,
+ '-' => UnixFileStatus.None,
+ _ => throw new ArgumentOutOfRangeException(nameof(code), $"The char of index {index} should be 'x', 's', 'S' or '-', but it is {code[index]}.")
+ };
+ mode |= code[--index] switch
+ {
+ 'w' => UnixFileStatus.GroupWrite,
+ '-' => UnixFileStatus.None,
+ _ => throw new ArgumentOutOfRangeException(nameof(code), $"The char of index {index} should be 'w' or '-', but it is {code[index]}.")
+ };
+ mode |= code[--index] switch
+ {
+ 'r' => UnixFileStatus.GroupRead,
+ '-' => UnixFileStatus.None,
+ _ => throw new ArgumentOutOfRangeException(nameof(code), $"The char of index {index} should be 'r' or '-', but it is {code[index]}.")
+ };
+
+ mode |= code[--index] switch
+ {
+ 'x' => UnixFileStatus.UserExecute,
+ 's' => UnixFileStatus.SetUser | UnixFileStatus.UserExecute,
+ 'S' => UnixFileStatus.SetUser,
+ '-' => UnixFileStatus.None,
+ _ => throw new ArgumentOutOfRangeException(nameof(code), $"The char of index {index} should be 'x', 's', 'S' or '-', but it is {code[index]}.")
+ };
+ mode |= code[--index] switch
+ {
+ 'w' => UnixFileStatus.UserWrite,
+ '-' => UnixFileStatus.None,
+ _ => throw new ArgumentOutOfRangeException(nameof(code), $"The char of index {index} should be 'w' or '-', but it is {code[index]}.")
+ };
+ mode |= code[--index] switch
+ {
+ 'r' => UnixFileStatus.UserRead,
+ '-' => UnixFileStatus.None,
+ _ => throw new ArgumentOutOfRangeException(nameof(code), $"The char of index {index} should be 'r' or '-', but it is {code[index]}.")
+ };
+
+ if (index == 1)
+ {
+ mode |= code[0] switch
+ {
+ 'p' => UnixFileStatus.FIFO,
+ 'c' => UnixFileStatus.Character,
+ 'd' => UnixFileStatus.Directory,
+ 'b' => UnixFileStatus.Block,
+ '-' => UnixFileStatus.Regular,
+ 'l' => UnixFileStatus.SymbolicLink,
+ 's' => UnixFileStatus.Socket,
+ _ => UnixFileStatus.None
+ };
+ }
+
+ return mode;
+ }
+
+ ///
+ /// Provides a string representation of the given .
+ ///
+ /// The to process.
+ /// A string representation of the given .
+ public static string ToPermissionCode(this UnixFileStatus mode)
+ {
+#if HAS_BUFFERS
+ Span code = stackalloc char[10];
+#else
+ char[] code = new char[10];
+#endif
+ BitArray array = new([(int)mode]);
+
+ code[9] = array[0]
+ ? array[9] ? 't' : 'x'
+ : array[9] ? 'T' : '-';
+ code[8] = array[1] ? 'w' : '-';
+ code[7] = array[2] ? 'r' : '-';
+
+ code[6] = array[3]
+ ? array[10] ? 's' : 'x'
+ : array[10] ? 'S' : '-';
+ code[5] = array[4] ? 'w' : '-';
+ code[4] = array[5] ? 'r' : '-';
+
+ code[3] = array[6]
+ ? array[11] ? 's' : 'x'
+ : array[11] ? 'S' : '-';
+ code[2] = array[7] ? 'w' : '-';
+ code[1] = array[8] ? 'r' : '-';
+
+ code[0] = mode.GetFileType() switch
+ {
+ UnixFileStatus.FIFO => 'p',
+ UnixFileStatus.Character => 'c',
+ UnixFileStatus.Directory => 'd',
+ UnixFileStatus.Block => 'b',
+ UnixFileStatus.Regular => '-',
+ UnixFileStatus.SymbolicLink => 'l',
+ UnixFileStatus.Socket => 's',
+ UnixFileStatus.None => '\0',
+ _ => '?'
+ };
+
+ return new string(code);
+ }
+
+ ///
+ /// Returns an enumerator that iterates through the .
+ ///
+ /// An enumerator that can be used to iterate through the .
+ public static IEnumerator GetEnumerator(this UnixFileStatus mode)
+ {
+ int num = (int)mode;
+ yield return (byte)num;
+ yield return (byte)(num >> 8);
+ yield return (byte)(num >> 16);
+ yield return (byte)(num >> 24);
+ }
+ }
+}
diff --git a/AdvancedSharpAdbClient/Interfaces/IAdbSocket.Async.cs b/AdvancedSharpAdbClient/Interfaces/IAdbSocket.Async.cs
index f4fbfd7..4a8b45c 100644
--- a/AdvancedSharpAdbClient/Interfaces/IAdbSocket.Async.cs
+++ b/AdvancedSharpAdbClient/Interfaces/IAdbSocket.Async.cs
@@ -56,7 +56,7 @@ public partial interface IAdbSocket
/// If the command is a command, the permissions to assign to the newly created file.
/// A that can be used to cancel the task.
/// A which represents the asynchronous operation.
- Task SendSyncRequestAsync(SyncCommand command, string path, int permissions, CancellationToken cancellationToken);
+ Task SendSyncRequestAsync(SyncCommand command, string path, UnixFileStatus permissions, CancellationToken cancellationToken);
///
/// Asynchronously sends a sync request to the device.
diff --git a/AdvancedSharpAdbClient/Interfaces/IAdbSocket.cs b/AdvancedSharpAdbClient/Interfaces/IAdbSocket.cs
index a16e20a..0120c57 100644
--- a/AdvancedSharpAdbClient/Interfaces/IAdbSocket.cs
+++ b/AdvancedSharpAdbClient/Interfaces/IAdbSocket.cs
@@ -54,7 +54,7 @@ public partial interface IAdbSocket : IDisposable
/// The command to send.
/// The path of the file on which the command should operate.
/// If the command is a command, the permissions to assign to the newly created file.
- void SendSyncRequest(SyncCommand command, string path, int permissions);
+ void SendSyncRequest(SyncCommand command, string path, UnixFileStatus permissions);
///
/// Sends a sync request to the device.
diff --git a/AdvancedSharpAdbClient/Interfaces/ISyncService.Async.cs b/AdvancedSharpAdbClient/Interfaces/ISyncService.Async.cs
index 17de608..010ebbe 100644
--- a/AdvancedSharpAdbClient/Interfaces/ISyncService.Async.cs
+++ b/AdvancedSharpAdbClient/Interfaces/ISyncService.Async.cs
@@ -17,13 +17,12 @@ public partial interface ISyncService
///
/// A that contains the contents of the file.
/// The path, on the device, to which to push the file.
- /// The permission octet that contains the permissions of the newly created file on the device.
+ /// The that contains the permissions of the newly created file on the device.
/// The time at which the file was last modified.
/// An optional parameter which, when specified, returns progress notifications. The progress is reported as , representing the state of the file which has been transferred.
/// A that can be used to cancel the task.
/// A which represents the asynchronous operation.
- /// The should coverts to a decimal number. For example, 644 should be 420 in decimal, &O644 in VB.NET and 0o644 in F# and Python.
- Task PushAsync(Stream stream, string remotePath, int permissions, DateTimeOffset timestamp, Action? callback, CancellationToken cancellationToken);
+ Task PushAsync(Stream stream, string remotePath, UnixFileStatus permissions, DateTimeOffset timestamp, Action? callback, CancellationToken cancellationToken);
///
/// Asynchronously pulls (downloads) a file from the remote device.
@@ -87,13 +86,12 @@ public interface IWinRT
///
/// A that contains the contents of the file.
/// The path, on the device, to which to push the file.
- /// The permission octet that contains the permissions of the newly created file on the device.
+ /// The that contains the permissions of the newly created file on the device.
/// The time at which the file was last modified.
/// An optional parameter which, when specified, returns progress notifications. The progress is reported as , representing the state of the file which has been transferred.
/// A that can be used to cancel the task.
/// A which represents the asynchronous operation.
- /// The should coverts to a decimal number. For example, 644 should be 420 in decimal, &O644 in VB.NET and 0o644 in F# and Python.
- Task PushAsync(IInputStream stream, string remotePath, int permissions, DateTimeOffset timestamp, Action? callback, CancellationToken cancellationToken);
+ Task PushAsync(IInputStream stream, string remotePath, UnixFileStatus permissions, DateTimeOffset timestamp, Action? callback, CancellationToken cancellationToken);
///
/// Asynchronously pulls (downloads) a file from the remote device.
diff --git a/AdvancedSharpAdbClient/Interfaces/ISyncService.cs b/AdvancedSharpAdbClient/Interfaces/ISyncService.cs
index 0bd93ab..1945f64 100644
--- a/AdvancedSharpAdbClient/Interfaces/ISyncService.cs
+++ b/AdvancedSharpAdbClient/Interfaces/ISyncService.cs
@@ -26,12 +26,11 @@ public partial interface ISyncService : IDisposable
///
/// A that contains the contents of the file.
/// The path, on the device, to which to push the file.
- /// The permission octet that contains the permissions of the newly created file on the device.
+ /// The that contains the permissions of the newly created file on the device.
/// The time at which the file was last modified.
/// An optional parameter which, when specified, returns progress notifications. The progress is reported as , representing the state of the file which has been transferred.
/// A that can be used to cancel the task.
- /// The should coverts to a decimal number. For example, 644 should be 420 in decimal, &O644 in VB.NET and 0o644 in F# and Python.
- void Push(Stream stream, string remotePath, int permissions, DateTimeOffset timestamp, Action? callback, in bool isCancelled);
+ void Push(Stream stream, string remotePath, UnixFileStatus permissions, DateTimeOffset timestamp, Action? callback, in bool isCancelled);
///
/// Pulls (downloads) a file from the remote device.
diff --git a/AdvancedSharpAdbClient/Models/Enums/UnixFileStatus.cs b/AdvancedSharpAdbClient/Models/Enums/UnixFileStatus.cs
new file mode 100644
index 0000000..2f7d076
--- /dev/null
+++ b/AdvancedSharpAdbClient/Models/Enums/UnixFileStatus.cs
@@ -0,0 +1,202 @@
+//
+// Copyright (c) The Android Open Source Project, Ryan Conrad, Quamotion, yungd1plomat, wherewhere. All rights reserved.
+//
+
+using System;
+
+namespace AdvancedSharpAdbClient.Models
+{
+ ///
+ /// Describes the properties of a file on an Android device.
+ ///
+ ///
+ [Flags]
+ public enum UnixFileStatus
+ {
+ ///
+ /// Empty property.
+ ///
+ /// Permission code: --------- (000)
+ None = 0x0000,
+
+ ///
+ /// Set user permission.
+ ///
+ /// Permission code: --S------ (4000)
+ SetUser = 0x0800,
+
+ ///
+ /// Set group permission.
+ ///
+ /// Permission code: -----S--- (2000)
+ SetGroup = 0x0400,
+
+ ///
+ /// Sticky bit permission.
+ ///
+ /// Permission code: --------T (1000)
+ StickyBit = 0x0200,
+
+ ///
+ /// Read permission for owner.
+ ///
+ /// Permission code: r-------- (400)
+ UserRead = 0x0100,
+
+ ///
+ /// Write permission for owner.
+ ///
+ /// Permission code: -w------- (200)
+ UserWrite = 0x0080,
+
+ ///
+ /// Execute permission for owner.
+ ///
+ /// Permission code: --x------ (100)
+ UserExecute = 0x0040,
+
+ ///
+ /// All owner permissions.
+ ///
+ /// Permission code: rwx------ (700)
+ UserAll = UserRead | UserWrite | UserExecute,
+
+ ///
+ /// The mask that can be used to retrieve the RWX for owner from a .
+ ///
+ /// Gets RWX for owner by mode & .
+ UserMask = UserAll,
+
+ ///
+ /// Read permission for group.
+ ///
+ /// Permission code: ---r----- (040)
+ GroupRead = 0x0020,
+
+ ///
+ /// Write permission for group.
+ ///
+ /// Permission code: ----w---- (020)
+ GroupWrite = 0x0010,
+
+ ///
+ /// Execute permission for group.
+ ///
+ /// Permission code: -----x--- (010)
+ GroupExecute = 0x0008,
+
+ ///
+ /// All group permissions.
+ ///
+ /// Permission code: ---rwx--- (070)
+ GroupAll = GroupRead | GroupWrite | GroupExecute,
+
+ ///
+ /// The mask that can be used to retrieve the RWX for group from a .
+ ///
+ /// Gets RWX for group by mode & .
+ GroupMask = GroupAll,
+
+ ///
+ /// Read permission for others.
+ ///
+ /// Permission code: ------r-- (004)
+ OtherRead = 0x0004,
+
+ ///
+ /// Write permission for others.
+ ///
+ /// Permission code: -------w- (001)
+ OtherWrite = 0x0002,
+
+ ///
+ /// Execute permission for others.
+ ///
+ /// Permission code: --------x (001)
+ OtherExecute = 0x0001,
+
+ ///
+ /// All others permissions.
+ ///
+ /// Permission code: ------rwx (007)
+ OtherAll = OtherRead | OtherWrite | OtherExecute,
+
+ ///
+ /// The mask that can be used to retrieve the RWX for others from a .
+ ///
+ /// Gets RWX for others by mode & .
+ OtherMask = OtherAll,
+
+ ///
+ /// The mask that can be used to retrieve the file type from a .
+ ///
+ /// Gets file type by mode & .
+ TypeMask = FIFO | Character | Directory | Block | Regular | SymbolicLink | Socket,
+
+ ///
+ /// The file is a first-in first-out queue.
+ ///
+ /// Permission code: p---------
+ FIFO = 0x1000,
+
+ ///
+ /// The file is a character device.
+ ///
+ /// Permission code: c---------
+ Character = 0x2000,
+
+ ///
+ /// The file is a directory.
+ ///
+ /// Permission code: d---------
+ Directory = 0x4000,
+
+ ///
+ /// The file is a block device.
+ ///
+ /// Permission code: b---------
+ Block = 0x6000,
+
+ ///
+ /// The file is a regular file.
+ ///
+ /// Permission code: ----------
+ Regular = 0x8000,
+
+ ///
+ /// The file is a symbolic link.
+ ///
+ /// Permission code: l---------
+ SymbolicLink = 0xA000,
+
+ ///
+ /// The file is a Unix socket.
+ ///
+ /// Permission code: s---------
+ Socket = 0xC000,
+
+ ///
+ /// Save swapped text even after use.
+ ///
+ /// Permission code: --------T (1000)
+ VTX = StickyBit,
+
+ ///
+ /// All access permissions.
+ ///
+ /// Permission code: rwxrwxrwx (777)
+ AccessPermissions = UserMask | GroupMask | OtherMask,
+
+ ///
+ /// All permissions.
+ ///
+ /// Permission code: rwsrwsrwt (7777)
+ AllPermissions = SetUser | SetGroup | StickyBit | UserMask | GroupMask | OtherMask,
+
+ ///
+ /// The default file mode.
+ ///
+ /// Permission code: rw-rw-rw- (666)
+ DefaultFileMode = UserRead | UserWrite | GroupRead | GroupWrite | OtherRead | OtherWrite
+ }
+}
diff --git a/AdvancedSharpAdbClient/Models/Enums/UnixFileType.cs b/AdvancedSharpAdbClient/Models/Enums/UnixFileType.cs
deleted file mode 100644
index b202288..0000000
--- a/AdvancedSharpAdbClient/Models/Enums/UnixFileType.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-//
-// Copyright (c) The Android Open Source Project, Ryan Conrad, Quamotion, yungd1plomat, wherewhere. All rights reserved.
-//
-
-using System;
-
-namespace AdvancedSharpAdbClient.Models
-{
- ///
- /// Describes the properties of a file on an Android device.
- ///
- [Flags]
- public enum UnixFileType
- {
- ///
- /// The file is a Unix socket.
- ///
- Socket = 0xC000,
-
- ///
- /// The file is a symbolic link.
- ///
- SymbolicLink = 0xA000,
-
- ///
- /// The file is a regular file.
- ///
- Regular = 0x8000,
-
- ///
- /// The file is a block device.
- ///
- Block = 0x6000,
-
- ///
- /// The file is a directory.
- ///
- Directory = 0x4000,
-
- ///
- /// The file is a character device.
- ///
- Character = 0x2000,
-
- ///
- /// The file is a first-in first-out queue.
- ///
- FIFO = 0x1000,
-
- ///
- /// The mask that can be used to retrieve the file type from a .
- ///
- TypeMask = Regular
- }
-}
diff --git a/AdvancedSharpAdbClient/Models/FileStatistics.cs b/AdvancedSharpAdbClient/Models/FileStatistics.cs
index a4ae335..45205a8 100644
--- a/AdvancedSharpAdbClient/Models/FileStatistics.cs
+++ b/AdvancedSharpAdbClient/Models/FileStatistics.cs
@@ -13,10 +13,11 @@ namespace AdvancedSharpAdbClient.Models
///
/// Contains information about a file on the remote device.
///
+ ///
#if HAS_BUFFERS
[CollectionBuilder(typeof(EnumerableBuilder), nameof(EnumerableBuilder.FileStatisticsCreator))]
#endif
- [DebuggerDisplay($"{nameof(FileStatistics)} \\{{ {nameof(Path)} = {{{nameof(Path)}}}, {nameof(FileType)} = {{{nameof(FileType)}}}, {nameof(Size)} = {{{nameof(Size)}}}, {nameof(Time)} = {{{nameof(Time)}}} }}")]
+ [DebuggerDisplay($"{nameof(FileStatistics)} \\{{ {nameof(Path)} = {{{nameof(Path)}}}, {nameof(FileMode)} = {{{nameof(FileMode)}}}, {nameof(Size)} = {{{nameof(Size)}}}, {nameof(Time)} = {{{nameof(Time)}}} }}")]
public struct FileStatistics : IEquatable
{
///
@@ -30,9 +31,9 @@ public FileStatistics() { }
public string Path { get; set; } = string.Empty;
///
- /// Gets or sets the attributes of the file.
+ /// Gets or sets the attributes of the file.
///
- public UnixFileType FileType { get; init; }
+ public UnixFileStatus FileMode { get; init; }
///
/// Gets or sets the total file size, in bytes.
@@ -50,10 +51,11 @@ public FileStatistics() { }
/// An enumerator that can be used to iterate through the .
public readonly IEnumerator GetEnumerator()
{
- yield return (byte)FileType;
- yield return (byte)((int)FileType >> 8);
- yield return (byte)((int)FileType >> 16);
- yield return (byte)((int)FileType >> 24);
+ int mode = (int)FileMode;
+ yield return (byte)mode;
+ yield return (byte)(mode >> 8);
+ yield return (byte)(mode >> 16);
+ yield return (byte)(mode >> 24);
yield return (byte)Size;
yield return (byte)(Size >> 8);
@@ -73,7 +75,7 @@ public readonly IEnumerator GetEnumerator()
///
public readonly bool Equals(FileStatistics other) =>
Path == other.Path
- && FileType == other.FileType
+ && FileMode == other.FileMode
&& Size == other.Size
&& Time == other.Time;
@@ -94,9 +96,9 @@ public readonly bool Equals(FileStatistics other) =>
public static bool operator !=(FileStatistics left, FileStatistics right) => !left.Equals(right);
///
- public override readonly int GetHashCode() => HashCode.Combine(Path, FileType, Size, Time);
+ public override readonly int GetHashCode() => HashCode.Combine(Path, FileMode, Size, Time);
///
- public override readonly string ToString() => StringExtensions.Join('\t', FileType, Time, FileType, Path);
+ public override readonly string ToString() => StringExtensions.Join('\t', FileMode.ToPermissionCode(), Size, Time, Path);
}
}
diff --git a/AdvancedSharpAdbClient/Models/FramebufferHeader.cs b/AdvancedSharpAdbClient/Models/FramebufferHeader.cs
index 9845fd2..8be330e 100644
--- a/AdvancedSharpAdbClient/Models/FramebufferHeader.cs
+++ b/AdvancedSharpAdbClient/Models/FramebufferHeader.cs
@@ -343,7 +343,7 @@ private PixelFormat StandardizePixelFormat(byte[] buffer)
}
// Alpha can be present or absent, but must be 8 bytes long
- if (Alpha.Length is not 0 and not 8)
+ if (Alpha.Length is not (0 or 8))
{
throw new ArgumentOutOfRangeException($"The alpha length {Alpha.Length} is not supported");
}
diff --git a/AdvancedSharpAdbClient/SyncService.Async.cs b/AdvancedSharpAdbClient/SyncService.Async.cs
index 9b38d07..89fbb6c 100644
--- a/AdvancedSharpAdbClient/SyncService.Async.cs
+++ b/AdvancedSharpAdbClient/SyncService.Async.cs
@@ -36,7 +36,7 @@ public async Task ReopenAsync(CancellationToken cancellationToken = default)
}
///
- public virtual async Task PushAsync(Stream stream, string remotePath, int permissions, DateTimeOffset timestamp, Action? callback = null, CancellationToken cancellationToken = default)
+ public virtual async Task PushAsync(Stream stream, string remotePath, UnixFileStatus permission, DateTimeOffset timestamp, Action? callback = null, CancellationToken cancellationToken = default)
{
ExceptionExtensions.ThrowIfNull(stream);
ExceptionExtensions.ThrowIfNull(remotePath);
@@ -50,7 +50,7 @@ public virtual async Task PushAsync(Stream stream, string remotePath, int permis
try
{
- await Socket.SendSyncRequestAsync(SyncCommand.SEND, remotePath, permissions, cancellationToken).ConfigureAwait(false);
+ await Socket.SendSyncRequestAsync(SyncCommand.SEND, remotePath, permission, cancellationToken).ConfigureAwait(false);
// create the buffer used to read.
// we read max SYNC_DATA_MAX.
@@ -204,7 +204,7 @@ public virtual async Task PullAsync(string remotePath, Stream stream, Action
- public virtual async Task PushAsync(IInputStream stream, string remotePath, int permissions, DateTimeOffset timestamp, Action? progress = null, CancellationToken cancellationToken = default)
+ public virtual async Task PushAsync(IInputStream stream, string remotePath, UnixFileStatus permission, DateTimeOffset timestamp, Action? progress = null, CancellationToken cancellationToken = default)
{
ExceptionExtensions.ThrowIfNull(stream);
ExceptionExtensions.ThrowIfNull(remotePath);
@@ -218,7 +218,7 @@ public virtual async Task PushAsync(IInputStream stream, string remotePath, int
try
{
- await Socket.SendSyncRequestAsync(SyncCommand.SEND, remotePath, permissions, cancellationToken).ConfigureAwait(false);
+ await Socket.SendSyncRequestAsync(SyncCommand.SEND, remotePath, permission, cancellationToken).ConfigureAwait(false);
// create the buffer used to read.
// we read max SYNC_DATA_MAX.
@@ -510,7 +510,7 @@ protected async Task ReadStatisticsAsync(CancellationToken cance
int index = 0;
return new FileStatistics
{
- FileType = (UnixFileType)ReadInt32(statResult),
+ FileMode = (UnixFileStatus)ReadInt32(statResult),
Size = ReadInt32(statResult),
Time = DateTimeExtensions.FromUnixTimeSeconds(ReadInt32(statResult))
};
diff --git a/AdvancedSharpAdbClient/SyncService.cs b/AdvancedSharpAdbClient/SyncService.cs
index c2ca502..55c4e44 100644
--- a/AdvancedSharpAdbClient/SyncService.cs
+++ b/AdvancedSharpAdbClient/SyncService.cs
@@ -140,7 +140,7 @@ public void Reopen()
}
///
- public virtual void Push(Stream stream, string remotePath, int permissions, DateTimeOffset timestamp, Action? callback = null, in bool isCancelled = false)
+ public virtual void Push(Stream stream, string remotePath, UnixFileStatus permission, DateTimeOffset timestamp, Action? callback = null, in bool isCancelled = false)
{
ExceptionExtensions.ThrowIfNull(stream);
ExceptionExtensions.ThrowIfNull(remotePath);
@@ -154,7 +154,7 @@ public virtual void Push(Stream stream, string remotePath, int permissions, Date
try
{
- Socket.SendSyncRequest(SyncCommand.SEND, remotePath, permissions);
+ Socket.SendSyncRequest(SyncCommand.SEND, remotePath, permission);
// create the buffer used to read.
// we read max SYNC_DATA_MAX.
@@ -434,7 +434,7 @@ protected FileStatistics ReadStatistics()
int index = 0;
return new FileStatistics
{
- FileType = (UnixFileType)ReadInt32(statResult),
+ FileMode = (UnixFileStatus)ReadInt32(statResult),
Size = ReadInt32(statResult),
Time = DateTimeExtensions.FromUnixTimeSeconds(ReadInt32(statResult))
};
diff --git a/Directory.Build.props b/Directory.Build.props
index 9567416..b614067 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -24,7 +24,7 @@
https://github.com/SharpAdb/AdvancedSharpAdbClient
snupkg
.NET client for adb, Android Debug Bridge (AdvancedSharpAdbClient)
- 3.1.11
+ 3.2.11