Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using SharpAdbClient;
- namespace TestADBClient
- {
- class Program
- {
- static void Main(string[] args)
- {
- var device = AdbClient.Instance.GetDevices()[0];
- var receiver = new ConsoleOutputReceiver();
- AdbClient.Instance.ExecuteRemoteCommand("fdisk /dev/block/mmcblk0 -l", device, receiver);
- string output = receiver.ToString();
- string[] fdiskData = output.Split('\n');
- int sectorSize = 0;
- int[,] partitions = new Int32[256,2];
- foreach (string line in fdiskData)
- {
- if (line.Length > 21 && line.Substring(0, 21) == "Logical sector size: ")
- {
- sectorSize = Convert.ToInt32(line.Substring(21));
- }
- else
- {
- int[] data = new Int32[3];
- int curPos = 0;
- bool startParse = false;
- int lenght = line.Length;
- bool corrupt = false;
- if (lenght > 0)
- {
- for (int charI = 0; charI < lenght; charI++)
- {
- if (curPos < 3)
- {
- if (line[charI] != ' ' && line[charI] >= '0' && line[charI] <= '9')
- {
- if (startParse)
- {
- data[curPos] = data[curPos] * 10 + Convert.ToInt32(line[charI].ToString());
- }
- else
- {
- startParse = true;
- data[curPos] = Convert.ToInt32(line[charI].ToString());
- }
- }
- else
- {
- if (line[charI] == ' ')
- {
- if (startParse)
- {
- curPos++;
- startParse = false;
- }
- }
- else
- {
- charI = lenght;
- corrupt = true;
- }
- }
- }
- }
- if (!corrupt)
- {
- partitions[data[0] - 1,0] = data[1];
- partitions[data[0] - 1,1] = data[2];
- }
- }
- }
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement