Пример #1
0
        public bool PasteCut(ADBFile myfile, string path)
        {
            //FileAndDirectoryCounter++;
            ExternalMethod.CounterEx++;
            bool rslt = false;

            if (myfile.GetTag() == 'd')
            {
                CreateDirectory(path, myfile.Name.FixForbidCharInTerminal());
                foreach (ADBFile onefile in myfile.GetSubFiles())
                {
                    PasteCut(onefile, path + "/" + myfile.Name.FixForbidCharInTerminal());
                }
                rslt = true;
            }
            else
            {
                if (resultCommand(string.Format(@"mv {0} {1}", myfile.FullName.FixForbidCharInTerminal(), path)).Count() == 0)
                {
                    rslt = true;
                }
                rslt = false;
            }
            return(rslt);
        }
Пример #2
0
 public bool BackupToSystem(ADBFile myfile, string BackupPath)
 {
     ExternalMethod.CounterEx++;
     if (myfile.GetTag() == 'd')
     {
         Directory.CreateDirectory(BackupPath + @"\" + myfile.Name.nickName().DecodingText());
         foreach (ADBFile onefile in myfile.GetSubFiles())
         {
             BackupToSystem(onefile, BackupPath + @"\" + myfile.Name.nickName().DecodingText());
         }
         return(true);
     }
     else
     {
         string fullnamebackup = BackupPath + @"\" + myfile.FullName.returnFile(CurrentDevice).Name.Replace(@"\", string.Empty).DecodingText();
         if (File.Exists(fullnamebackup))
         {
             return(true);
         }
         using (SyncService service = new SyncService(new AdbSocket(new IPEndPoint(IPAddress.Loopback, AdbClient.AdbServerPort)), CurrentDevice))
             using (Stream stream = System.IO.File.OpenWrite(fullnamebackup))
             {
                 try
                 {
                     service.Pull(myfile.FullName.Replace(@"\", string.Empty), stream, null, CancellationToken.None);
                     return(true);
                 }
                 catch (Exception)
                 {
                     return(false);
                 }
             }
     }
 }
Пример #3
0
 public int CountFileAndDirectory(ADBFile myFile)
 {
     myFile.GetCountSubFiles();
     return(myFile.SubFilesNumber);
 }
Пример #4
0
        private List <ADBFile> ReturnListAdbFile_LinesLs(string result_LinesLs, string tmpDirectoryName)
        {
            //Should Return ADB File...
            //Fiels-------------------------------------------------------------
            List <string>   ValidLsLines            = new List <string>();
            List <string>   resultWords             = new List <string>();
            List <string[]> ListTagName             = new List <string[]>();
            StringReader    StreamReader_ResultCode = new StringReader(result_LinesLs);
            string          tempCheckLine;
            bool            firstTime = true;
            Regex           rgx       = new Regex(@"\d\d:\d\d");

            List <ADBFile> ListAdbFile = new List <ADBFile>();
            ADBFile        tmpAdbFile;
            string         tmpName, tmpTag;

            //Add Valid Code in ValidLsLines------------------------------------
            while (StreamReader_ResultCode.Peek() >= 0)
            {
                tempCheckLine = StreamReader_ResultCode.ReadLine();
                if (tempCheckLine.Contains("Permission denied") || tempCheckLine.Contains("total"))
                {
                    continue;
                }
                ValidLsLines.Add(tempCheckLine);
            }



            //Each Line Ls -l Get Tag & Name-------------------------------------
            foreach (string oneline in ValidLsLines)
            {
                resultWords = oneline.Split(' ').ToList();

                for (int i = 0; i < resultWords.Count; i++)
                {
                    if (rgx.IsMatch(resultWords[i]))
                    {
                        tempCheckLine = "";
                        firstTime     = true;
                        for (int j = i + 1; j < resultWords.Count; j++)
                        {
                            if (resultWords[j] == "->" && j < resultWords.Count)
                            {
                                break;
                            }
                            if (firstTime)
                            {
                                tempCheckLine += resultWords[j];
                                firstTime      = false;
                            }
                            else
                            {
                                tempCheckLine += @"\ " + resultWords[j];
                            }
                        }
                        tmpName    = tempCheckLine;
                        tmpTag     = oneline[0].ToString();
                        tmpAdbFile = new ADBFile(device, tmpName, tmpDirectoryName, tmpTag, oneline);
                        ListAdbFile.Add(tmpAdbFile);
                        break;
                    }
                }
            }

            return(ListAdbFile);
        }