//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public string Pull(string remotePath, string localPath) { LoggingUtils.PrintFunction(); try { // // Check if the remote path is a symbolic link, and adjust the target file. // (ADB Pull doesn't follow these links) // try { string readlink = Shell("readlink", remotePath).Replace("\r", "").Replace("\n", ""); if (readlink.StartsWith("/")) // absolute path link { remotePath = readlink; } else // relative path link { int i = remotePath.LastIndexOf('/'); if (i != -1) { string parentPath = remotePath.Substring(0, i); string file = remotePath.Substring(i + 1); remotePath = parentPath + '/' + file; } } } catch (Exception) { // Ignore. Not a relative link. } // // Pull the requested file. // int exitCode = -1; using (SyncRedirectProcess process = AndroidAdb.AdbCommand(this, "pull", string.Format("{0} {1}", remotePath, PathUtils.QuoteIfNeeded(localPath)))) { exitCode = process.StartAndWaitForExit(); if (exitCode != 0) { throw new InvalidOperationException(string.Format("[pull] returned error code: {0}", exitCode)); } return(process.StandardOutput); } } catch (Exception e) { LoggingUtils.HandleException(e); throw new InvalidOperationException("[pull] failed", e); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public string Push(string localPath, string remotePath) { LoggingUtils.PrintFunction(); try { int exitCode = -1; using (SyncRedirectProcess process = AndroidAdb.AdbCommand(this, "push", string.Format("{0} {1}", PathUtils.QuoteIfNeeded(localPath), remotePath))) { exitCode = process.StartAndWaitForExit(); if (exitCode != 0) { throw new InvalidOperationException(string.Format("[push] returned error code: {0}", exitCode)); } return(process.StandardOutput); } } catch (Exception e) { LoggingUtils.HandleException(e); throw new InvalidOperationException("[push] failed", e); } }