/// <summary> /// Pushes a file to device /// </summary> /// <param name="localFilePath">the absolute path to file on local host</param> /// <returns>destination path on device for file</returns> /// <exception cref="IOException">if fatal error occurred when pushing file</exception> public string SyncPackageToDevice(string localFilePath) { try { string packageFileName = Path.GetFileName(localFilePath); // only root has access to /data/local/tmp/... not sure how adb does it then... // workitem: 16823 // string remoteFilePath = string.Format ( "/data/local/tmp/{0}", packageFileName ); string remoteFilePath = LinuxPath.Combine(TEMP_DIRECTORY_FOR_INSTALL, packageFileName); Log.D(LOG_TAG, string.Format("Uploading {0} onto device '{1}'", packageFileName, this)); SyncService sync = SyncService; if (sync != null) { string message = string.Format("Uploading file onto device '{0}'", this); Log.D(LOG_TAG, message); SyncResult result = sync.PushFile(localFilePath, remoteFilePath, SyncService.NullProgressMonitor); if (result.Code != ErrorCodeHelper.RESULT_OK) { throw new IOException(string.Format("Unable to upload file: {0}", result.Message)); } } else { throw new IOException("Unable to open sync connection!"); } return(remoteFilePath); } catch (IOException e) { Log.E(LOG_TAG, string.Format("Unable to open sync connection! reason: {0}", e.Message)); throw; } }
/// <summary> /// Gets the file type from the mode /// </summary> /// <param name="mode">the file mode flags</param> /// <returns></returns> private static FileTypes GetFileType(SyncService.FileMode mode) { if ((mode & SyncService.FileMode.Socket) == SyncService.FileMode.Socket) { return FileListingService.FileTypes.Socket; } if ((mode & SyncService.FileMode.SymbolicLink) == SyncService.FileMode.SymbolicLink) { return FileListingService.FileTypes.Link; } if ((mode & SyncService.FileMode.Regular) == SyncService.FileMode.Regular) { return FileListingService.FileTypes.File; } if ((mode & SyncService.FileMode.Block) == SyncService.FileMode.Block) { return FileListingService.FileTypes.Block; } if ((mode & SyncService.FileMode.Directory) == SyncService.FileMode.Directory) { return FileListingService.FileTypes.Directory; } if ((mode & SyncService.FileMode.Character) == SyncService.FileMode.Character) { return FileListingService.FileTypes.Character; } if ((mode & SyncService.FileMode.FIFO) == SyncService.FileMode.FIFO) { return FileListingService.FileTypes.FIFO; } return FileListingService.FileTypes.Other; }