/// <summary> /// Push a single file. /// </summary> /// <param name="local">the local filepath.</param> /// <param name="remote">The remote filepath.</param> /// <param name="monitor">The progress monitor. Cannot be null.</param> /// <returns> /// a SyncResult object with a code and an optional message. /// </returns> /// <exception cref="System.ArgumentNullException">monitor;Monitor cannot be null</exception> /// <exception cref="ArgumentNullException">Throws if monitor is null</exception> public SyncResult PushFile(String local, String remote, ISyncProgressMonitor monitor) { if (monitor == null) { throw new ArgumentNullException("monitor", "Monitor cannot be null"); } FileInfo f = new FileInfo(local); if (!f.Exists) { return(new SyncResult(ErrorCodeHelper.RESULT_NO_LOCAL_FILE)); } if (f.IsDirectory( )) { return(new SyncResult(ErrorCodeHelper.RESULT_LOCAL_IS_DIRECTORY)); } monitor.Start(f.Length); SyncResult result = DoPushFile(local, remote, monitor); monitor.Stop( ); return(result); }
/// <include file='.\ISyncService.xml' path='/SyncService/Pull/*'/> public static SyncResult Pull(this ISyncService syncService, IEnumerable<FileEntry> entries, String localPath, ISyncProgressMonitor monitor) { if (monitor == null) { throw new ArgumentNullException("monitor", "Monitor cannot be null"); } // first we check the destination is a directory and exists DirectoryInfo d = new DirectoryInfo(localPath); if (!d.Exists) { return new SyncResult(ErrorCodeHelper.RESULT_NO_DIR_TARGET); } if (!d.IsDirectory()) { return new SyncResult(ErrorCodeHelper.RESULT_TARGET_IS_FILE); } // get a FileListingService object FileListingService fls = new FileListingService(syncService.Device); // compute the number of file to move long total = GetTotalRemoteFileSize(entries, fls); Log.i(TAG, "total transfer: {0}", total); // start the monitor monitor.Start(total); SyncResult result = syncService.DoPull(entries, localPath, fls, monitor); monitor.Stop(); return result; }
/// <summary> /// Push several files. /// </summary> /// <param name="local">An array of local files to push</param> /// <param name="remote">the remote FileEntry representing a directory.</param> /// <param name="monitor">The progress monitor. Cannot be null.</param> /// <returns> /// a SyncResult object with a code and an optional message. /// </returns> /// <exception cref="System.ArgumentNullException">Monitor cannot be null</exception> /// <gist id="380b3c149499bf31e49d" /> public SyncResult Push(IEnumerable <String> local, FileEntry remote, ISyncProgressMonitor monitor) { if (monitor == null) { throw new ArgumentNullException("monitor", "Monitor cannot be null"); } if (!remote.IsDirectory) { return(new SyncResult(ErrorCodeHelper.RESULT_REMOTE_IS_FILE)); } // make a list of File from the list of String List <FileSystemInfo> files = new List <FileSystemInfo> ( ); foreach (String path in local) { files.Add(path.GetFileSystemInfo( )); } // get the total count of the bytes to transfer long total = GetTotalLocalFileSize(files); monitor.Start(total); SyncResult result = DoPush(files, remote.FullPath, monitor); monitor.Stop( ); return(result); }
/// <summary> /// Pulls a single file. /// <para>Because this method just deals with a string for the remote file instead of FileEntry, /// the size of the file being pulled is unknown and the ISyncProgressMonitor will not properly /// show the progress</para> /// </summary> /// <param name="remoteFilepath">the full path to the remote file</param> /// <param name="localFilename">The local destination.</param> /// <param name="monitor">The progress monitor. Cannot be null.</param> /// <returns>a SyncResult object with a code and an optional message.</returns> /// <exception cref="ArgumentNullException">Throws if monitor is null</exception> public SyncResult PullFile(string remoteFilepath, string localFilename, ISyncProgressMonitor monitor) { if (monitor == null) { throw new ArgumentNullException("monitor", "Monitor cannot be null"); } long totalWork = 0; try { FileListingService fls = new FileListingService(this.Device); FileEntry remoteFileEntry = fls.FindFileEntry(remoteFilepath); totalWork = remoteFileEntry.Size; } catch (FileNotFoundException ffe) { Log.W(TAG, ffe); } monitor.Start(totalWork); SyncResult result = DoPullFile(remoteFilepath, localFilename, monitor); monitor.Stop(); return(result); }
/// <include file='.\ISyncService.xml' path='/SyncService/PullFile/*'/> public static SyncResult PullFile(this ISyncService syncService, FileEntry remote, String localFilename, ISyncProgressMonitor monitor) { if (monitor == null) { throw new ArgumentNullException("monitor", "Monitor cannot be null"); } long total = remote.Size; monitor.Start(total); SyncResult result = syncService.DoPullFile(remote.FullPath, localFilename, monitor); monitor.Stop(); return result; }
/// <summary> /// Pulls a single file. /// </summary> /// <param name="remote">remote the remote file</param> /// <param name="localFilename">The local destination.</param> /// <param name="monitor">The progress monitor. Cannot be null.</param> /// <returns> /// a SyncResult object with a code and an optional message. /// </returns> /// <exception cref="System.ArgumentNullException">monitor;Monitor cannot be null</exception> /// <exception cref="ArgumentNullException">Throws if monitor is null</exception> /// <gist id="39fdc76b6f394b9bdf88" /> public SyncResult PullFile(FileEntry remote, String localFilename, ISyncProgressMonitor monitor) { if (monitor == null) { throw new ArgumentNullException("monitor", "Monitor cannot be null"); } long total = remote.Size; monitor.Start(total); SyncResult result = DoPullFile(remote.FullPath, localFilename, monitor); monitor.Stop( ); return(result); }
/// <include file='.\ISyncService.xml' path='/SyncService/PullFile2/*'/> public SyncResult PullFile(string remoteFilepath, string localFilename, ISyncProgressMonitor monitor) { if (monitor == null) { throw new ArgumentNullException("monitor", "Monitor cannot be null"); } long totalWork = 0; monitor.Start(totalWork); SyncResult result = this.DoPullFile(remoteFilepath, localFilename, monitor); monitor.Stop(); return(result); }
/// <summary> /// Pulls file(s) or folder(s). /// </summary> /// <param name="entries">the remote item(s) to pull</param> /// <param name="localPath">The local destination. If the entries count is > 1 or if the unique entry is a /// folder, this should be a folder.</param> /// <param name="monitor">The progress monitor. Cannot be null.</param> /// <returns> /// a SyncResult object with a code and an optional message. /// </returns> /// <exception cref="System.ArgumentNullException">monitor;Monitor cannot be null</exception> /// <gist id="c9ca09c0c0779d0a5fb8" /> public SyncResult Pull(IEnumerable <FileEntry> entries, String localPath, ISyncProgressMonitor monitor) { if (monitor == null) { throw new ArgumentNullException("monitor", "Monitor cannot be null"); } // first we check the destination is a directory and exists DirectoryInfo d = new DirectoryInfo(localPath); if (!d.Exists) { return(new SyncResult(ErrorCodeHelper.RESULT_NO_DIR_TARGET)); } if (!d.IsDirectory()) { return(new SyncResult(ErrorCodeHelper.RESULT_TARGET_IS_FILE)); } // get a FileListingService object FileListingService fls = new FileListingService(Device); // compute the number of file to move long total = GetTotalRemoteFileSize(entries, fls); Log.d(TAG, "total transfer: {0}", total); // start the monitor monitor.Start(total); SyncResult result = DoPull(entries, localPath, fls, monitor); monitor.Stop( ); return(result); }
/// <summary> /// Push a single file. /// </summary> /// <param name="local">the local filepath.</param> /// <param name="remote">The remote filepath.</param> /// <param name="monitor">The progress monitor. Cannot be null.</param> /// <returns> /// a SyncResult object with a code and an optional message. /// </returns> /// <exception cref="System.ArgumentNullException">monitor;Monitor cannot be null</exception> /// <exception cref="ArgumentNullException">Throws if monitor is null</exception> public SyncResult PushFile( String local, String remote, ISyncProgressMonitor monitor ) { if ( monitor == null ) { throw new ArgumentNullException ( "monitor", "Monitor cannot be null" ); } FileInfo f = new FileInfo ( local ); if ( !f.Exists ) { return new SyncResult ( ErrorCodeHelper.RESULT_NO_LOCAL_FILE ); } if ( f.IsDirectory ( ) ) { return new SyncResult ( ErrorCodeHelper.RESULT_LOCAL_IS_DIRECTORY ); } monitor.Start ( f.Length ); SyncResult result = DoPushFile ( local, remote, monitor ); monitor.Stop ( ); return result; }
/// <summary> /// Push several files. /// </summary> /// <param name="local">An array of local files to push</param> /// <param name="remote">the remote FileEntry representing a directory.</param> /// <param name="monitor">The progress monitor. Cannot be null.</param> /// <returns> /// a SyncResult object with a code and an optional message. /// </returns> /// <exception cref="System.ArgumentNullException">Monitor cannot be null</exception> /// <gist id="380b3c149499bf31e49d" /> public SyncResult Push( IEnumerable<String> local, FileEntry remote, ISyncProgressMonitor monitor ) { if ( monitor == null ) { throw new ArgumentNullException ( "monitor", "Monitor cannot be null" ); } if ( !remote.IsDirectory ) { return new SyncResult ( ErrorCodeHelper.RESULT_REMOTE_IS_FILE ); } // make a list of File from the list of String List<FileSystemInfo> files = new List<FileSystemInfo> ( ); foreach ( String path in local ) { files.Add ( path.GetFileSystemInfo ( ) ); } // get the total count of the bytes to transfer long total = GetTotalLocalFileSize ( files ); monitor.Start ( total ); SyncResult result = DoPush ( files, remote.FullPath, monitor ); monitor.Stop ( ); return result; }
/// <summary> /// Pulls a single file. /// <para>Because this method just deals with a String for the remote file instead of FileEntry, /// the size of the file being pulled is unknown and the ISyncProgressMonitor will not properly /// show the progress</para> /// </summary> /// <param name="remoteFilepath">the full path to the remote file</param> /// <param name="localFilename">The local destination.</param> /// <param name="monitor">The progress monitor. Cannot be null.</param> /// <returns> /// a SyncResult object with a code and an optional message. /// </returns> /// <exception cref="System.ArgumentNullException">monitor;Monitor cannot be null</exception> /// <exception cref="ArgumentNullException">Throws if monitor is null</exception> /// <gist id="9021e6c39ee20a6e122b" /> public SyncResult PullFile( String remoteFilepath, String localFilename, ISyncProgressMonitor monitor ) { if ( monitor == null ) { throw new ArgumentNullException ( "monitor", "Monitor cannot be null" ); } long totalWork = 0; try { FileListingService fls = new FileListingService ( this.Device ); FileEntry remoteFileEntry = fls.FindFileEntry ( remoteFilepath ); totalWork = remoteFileEntry.Size; } catch ( FileNotFoundException ffe ) { Console.WriteLine ( ffe.ToString ( ) ); Log.w ( "ddms", ffe ); } monitor.Start ( totalWork ); SyncResult result = DoPullFile ( remoteFilepath, localFilename, monitor ); monitor.Stop ( ); return result; }
/// <include file='.\ISyncService.xml' path='/SyncService/PullFile2/*'/> public SyncResult PullFile(string remoteFilepath, string localFilename, ISyncProgressMonitor monitor) { if (monitor == null) { throw new ArgumentNullException("monitor", "Monitor cannot be null"); } long totalWork = 0; monitor.Start(totalWork); SyncResult result = this.DoPullFile(remoteFilepath, localFilename, monitor); monitor.Stop(); return result; }