public override void DownloadFile(string sourceFileSpec, string targetFileSpec) { sourceFileSpec = sourceFileSpec.Replace(@"\", @"/"); sourceFileSpec = Connector.StripDrivePrefix(sourceFileSpec); sourceFileSpec = sourceFileSpec.Trim(); if (!sourceFileSpec.StartsWith(SDCARD_PREFIX)) { sourceFileSpec = SDCARD_PREFIX + sourceFileSpec; } string commandLine = Administrator.ProfileManager.SystemProfile.ADB + string.Format(DOWNLOAD_FILE_COMMAND_TEMPLATE, sourceFileSpec, targetFileSpec); CommandLauncher launcher = new CommandLauncher(); launcher.Run(commandLine); List <string> lines = launcher.OutputLines; int exitCode = launcher.ExitCode; }
public override void RemoveDirectory(string targetDirectory) { targetDirectory = targetDirectory.Replace(@"\", @"/"); targetDirectory = Connector.StripDrivePrefix(targetDirectory); targetDirectory = targetDirectory.Trim(); if (!targetDirectory.StartsWith(SDCARD_PREFIX)) { targetDirectory = SDCARD_PREFIX + targetDirectory; } string commandLine = Administrator.ProfileManager.SystemProfile.ADB + string.Format(REMOVE_DIRECTORY_COMMAND_TEMPLATE, targetDirectory); CommandLauncher launcher = new CommandLauncher(); launcher.Run(commandLine); List <string> lines = launcher.OutputLines; int exitCode = launcher.ExitCode; }
public override void DeleteFile(string targetFileSpec) { targetFileSpec = targetFileSpec.Replace(@"\", @"/"); targetFileSpec = Connector.StripDrivePrefix(targetFileSpec); targetFileSpec = EscapeSpaces(targetFileSpec); targetFileSpec = targetFileSpec.Trim(); if (!targetFileSpec.StartsWith(SDCARD_PREFIX)) { targetFileSpec = SDCARD_PREFIX + targetFileSpec; } string commandLine = Administrator.ProfileManager.SystemProfile.ADB + string.Format(DELETE_FILE_COMMAND_TEMPLATE, targetFileSpec); CommandLauncher launcher = new CommandLauncher(); launcher.Run(commandLine); List <string> lines = launcher.OutputLines; int exitCode = launcher.ExitCode; }
public override bool DirectoryExists(string targetDirectory) { targetDirectory = targetDirectory.Replace(@"\", @"/"); targetDirectory = Connector.StripDrivePrefix(targetDirectory); targetDirectory = targetDirectory.Trim(); if (!targetDirectory.StartsWith(SDCARD_PREFIX)) { targetDirectory = SDCARD_PREFIX + targetDirectory; } bool exists = false; try { string commandLine = Administrator.ProfileManager.SystemProfile.ADB + string.Format(DIRECTORY_LIST_COMMAND_TEMPLATE, targetDirectory); CommandLauncher launcher = new CommandLauncher(); launcher.Run(commandLine); List <string> lines = launcher.OutputLines; for (int row = 0; row < lines.Count; row++) { string line = lines[row]; if (line.Trim().Length == 0) { continue; } if (line.StartsWith("total")) { //Directory. exists = true; break; } else if (line.StartsWith("/")) { //No such file or directory. exists = false; break; } else if (line.StartsWith("d")) { //Directory. exists = true; break; } else if (line.ToLower().Contains("no such file or directory")) { //Directory. exists = false; break; } else if (line.ToLower().Contains("no such file")) { //Directory. exists = false; break; } else if (line.ToLower().Contains("no such directory")) { //Directory. exists = false; break; } else { //File. exists = true; break; } } } catch (Exception oException) { System.Diagnostics.Debug.WriteLine(oException.Message); } finally { } return(exists); }
public override DateTime FileModifiedDateTime(string targetFileSpec) { targetFileSpec = targetFileSpec.Replace(@"\", @"/"); targetFileSpec = Connector.StripDrivePrefix(targetFileSpec); targetFileSpec = EscapeSpaces(targetFileSpec); targetFileSpec = targetFileSpec.Trim(); if (!targetFileSpec.StartsWith(SDCARD_PREFIX)) { targetFileSpec = SDCARD_PREFIX + targetFileSpec; } string name = string.Empty; DateTime dateTime = DateTime.MinValue; try { string commandLine = Administrator.ProfileManager.SystemProfile.ADB + string.Format(DIRECTORY_LIST_COMMAND_TEMPLATE, targetFileSpec); CommandLauncher launcher = new CommandLauncher(); launcher.Run(commandLine); List <string> lines = launcher.OutputLines; for (int row = 0; row < lines.Count; row++) { string line = lines[row]; if (line.Trim().Length == 0) { continue; } if (line.StartsWith("total")) { continue; } string[] parts = line.Split(' '); int index = parts.Length - 1; string fileName = parts[index--]; string timeText = parts[index--]; string dateText = parts[index--]; string sizeText = parts[index--]; string dateTimeText = dateText + " " + timeText; if (line.StartsWith("/")) { //No such file or directory. } else if (line.StartsWith("d")) { //Directory. } else { //File. name = fileName; long size = 0; long.TryParse(sizeText, out size); dateTime = DateTime.MinValue; DateTime.TryParse(dateTimeText, out dateTime); } } } catch (Exception oException) { System.Diagnostics.Debug.WriteLine(oException.Message); } finally { } return(dateTime); }
public override bool FileExists(string targetFileSpec) { targetFileSpec = targetFileSpec.Replace(@"\", @"/"); targetFileSpec = EscapeSpaces(targetFileSpec); targetFileSpec = Connector.StripDrivePrefix(targetFileSpec); targetFileSpec = targetFileSpec.Trim(); if (!targetFileSpec.StartsWith(SDCARD_PREFIX)) { targetFileSpec = SDCARD_PREFIX + targetFileSpec; } bool exists = false; try { string commandLine = Administrator.ProfileManager.SystemProfile.ADB + string.Format(DIRECTORY_LIST_COMMAND_TEMPLATE, targetFileSpec); CommandLauncher launcher = new CommandLauncher(); launcher.Run(commandLine); List <string> lines = launcher.OutputLines; for (int row = 0; row < lines.Count; row++) { string line = lines[row]; if (line.Trim().Length == 0) { continue; } if (line.StartsWith("total")) { continue; } string[] parts = line.Split(' '); int index = parts.Length - 1; string fileName = parts[index--]; string timeText = parts[index--]; string dateText = parts[index--]; string sizeText = parts[index--]; string dateTimeText = dateText + " " + timeText; if (line.StartsWith("/")) { //No such file or directory. exists = false; break; } else if (line.StartsWith("d")) { //Directory. exists = false; break; } else if (line.ToLower().Contains("no such file or directory")) { //Directory. exists = false; break; } else if (line.ToLower().Contains("no such file")) { //Directory. exists = false; break; } else if (line.ToLower().Contains("no such directory")) { //Directory. exists = false; break; } else { //File. exists = true; } } } catch (Exception oException) { System.Diagnostics.Debug.WriteLine(oException.Message); } finally { } return(exists); }