/// <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; }
public bool Refresh(string path) { if (path != null) { try { var dir = new DirectoryInfo(path); if (dir.IsDirectory()) { workPathFragment.RefreshFilesList(path); } return true; } catch { } } return false; }
public void test001_Initalize() { var gitdir = new DirectoryInfo(trash.FullName + "/.git"); var objects = new DirectoryInfo(gitdir.FullName + "/objects"); var objects_pack = new DirectoryInfo(objects.FullName + "/pack"); var objects_info = new DirectoryInfo(objects.FullName + "/info"); var refs = new DirectoryInfo(gitdir.FullName + "/refs"); var refs_heads = new DirectoryInfo(refs.FullName + "/heads"); var refs_tags = new DirectoryInfo(refs.FullName + "/tags"); var HEAD = new FileInfo(gitdir.FullName + "/HEAD"); Assert.IsTrue(trash.IsDirectory(), "Exists " + trash); Assert.IsTrue(objects.IsDirectory(), "Exists " + objects); Assert.IsTrue(objects_pack.IsDirectory(), "Exists " + objects_pack); Assert.IsTrue(objects_info.IsDirectory(), "Exists " + objects_info); Assert.AreEqual(2, objects.ListFiles().Length); Assert.IsTrue(refs.IsDirectory(), "Exists " + refs); Assert.IsTrue(refs_heads.IsDirectory(), "Exists " + refs_heads); Assert.IsTrue(refs_tags.IsDirectory(), "Exists " + refs_tags); Assert.IsTrue(HEAD.IsFile(), "Exists " + HEAD); Assert.AreEqual(23, HEAD.Length); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.Inflate(Resource.Layout.work_path_fragment, container, false); workPathLayout = view.FindViewById<LinearLayout>(Resource.Id.work_path_layout); coordinatorLayout = view.FindViewById<CoordinatorLayout>(Resource.Id.coordinator_layout); string workPath = Pref.WorkPath; workPathFragment = (FileListFragment)ChildFragmentManager.FindFragmentById(Resource.Id.work_path_fragment); workPathFragment.RefreshFilesList(workPath); workPathFragment.SnackbarView = coordinatorLayout; //workPathFragment.PrefKey = Pref.WorkPathKey; etWorkPath = view.FindViewById<EditText>(Resource.Id.etWorkPath); etWorkPath.Text = workPath; etWorkPath.FocusChange += (object sender, View.FocusChangeEventArgs e) => { try { var dir = new DirectoryInfo(etWorkPath.Text); if (dir.IsDirectory()) { Pref.WorkPath = etWorkPath.Text; } else { Show("잘못된 경로: " + etWorkPath.Text); etWorkPath.Text = Pref.WorkPath; } } catch { Show("잘못된 경로: " + etWorkPath.Text); etWorkPath.Text = Pref.WorkPath; } workPathFragment.RefreshFilesList(etWorkPath.Text); }; etWorkPath.KeyPress += (object sender, View.KeyEventArgs e) => { e.Handled = false; if (e.KeyCode == Keycode.Enter || e.KeyCode == Keycode.Back || e.KeyCode == Keycode.Escape) { var imm = (InputMethodManager)Context.GetSystemService(Context.InputMethodService); imm.HideSoftInputFromWindow(etWorkPath.WindowToken, 0); etWorkPath.ClearFocus(); e.Handled = true; } }; workPathToolbar = view.FindViewById<Toolbar>(Resource.Id.work_path_toolbar); workPathToolbar.InflateMenu(Resource.Menu.toolbar_work_path_menu); workPathToolbar.MenuItemClick += (sender, e) => { //Toast.MakeText(this, "Bottom toolbar pressed: " + e.Item.TitleFormatted, ToastLength.Short).Show(); bool ret; switch (e.Item.ItemId) { case Resource.Id.toolbar_work_path_menu_up: OnBackPressedFragment(); break; case Resource.Id.toolbar_work_path_menu_home: if (!Refresh(Pref.WorkPath)) Show("경로 이동 실패: " + Pref.WorkPath); break; case Resource.Id.toolbar_work_path_menu_storage: if (!Refresh("/storage")) Show("경로 이동 실패: " + "/storage"); break; case Resource.Id.toolbar_work_path_menu_sdcard: if (!Refresh(Environment.ExternalStorageDirectory.AbsolutePath)) Show("경로 이동 실패: " + Environment.ExternalStorageDirectory.AbsolutePath); break; case Resource.Id.toolbar_work_path_menu_extsdcard: ret = false; try { var dir = new DirectoryInfo("/storage"); foreach (var item in dir.GetDirectories()) { if (item.Name.ToLower().StartsWith("ext") || item.Name.ToLower().StartsWith("sdcard1")) { foreach (var subItem in item.GetFileSystemInfos()) { if (Refresh(item.FullName)) { ret = true; break; } } } } } catch { } if (!ret) Show("경로 이동 실패: " + "SD 카드"); break; case Resource.Id.toolbar_work_path_menu_usbstorage: ret = false; try { var dir = new DirectoryInfo("/storage"); foreach (var item in dir.GetDirectories()) { if (item.Name.ToLower().StartsWith("usb")) { foreach (var subItem in item.GetFileSystemInfos()) { if (Refresh(item.FullName)) { ret = true; break; } } } } } catch { } if (!ret) Show("경로 이동 실패: " + "USB 저장소"); break; } }; fab = view.FindViewById<FloatingActionButton>(Resource.Id.fab); fab.Click += (sender, e) => { etWorkPath.Text = workPathFragment.DirPath; Pref.WorkPath = etWorkPath.Text; workPathFragment.RefreshFilesList(); Show("경로 설정 완료: " + etWorkPath.Text); }; return view; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.Inflate(Resource.Layout.backup_path_fragment, container, false); backupPathLayout = view.FindViewById<LinearLayout>(Resource.Id.backup_path_layout); coordinatorLayout = view.FindViewById<CoordinatorLayout>(Resource.Id.coordinator_layout); string backupPath = Pref.BackupPath; backupPathFragment = (FileListFragment)ChildFragmentManager.FindFragmentById(Resource.Id.backup_path_fragment); backupPathFragment.RefreshFilesList(backupPath); backupPathFragment.SnackbarView = coordinatorLayout; //backupPathFragment.PrefKey = Pref.BackupPathKey; etBackupPath = view.FindViewById<EditText>(Resource.Id.etBackupPath); etBackupPath.Text = backupPath; etBackupPath.FocusChange += (object sender, View.FocusChangeEventArgs e) => { try { var dir = new DirectoryInfo(etBackupPath.Text); if (dir.IsDirectory()) { Pref.BackupPath = etBackupPath.Text; } else { Show("잘못된 경로: " + etBackupPath.Text); etBackupPath.Text = Pref.BackupPath; } } catch { Show("잘못된 경로: " + etBackupPath.Text); etBackupPath.Text = Pref.BackupPath; } backupPathFragment.RefreshFilesList(etBackupPath.Text); }; etBackupPath.KeyPress += (object sender, View.KeyEventArgs e) => { e.Handled = false; if (e.KeyCode == Keycode.Enter || e.KeyCode == Keycode.Back || e.KeyCode == Keycode.Escape) { var imm = (InputMethodManager)Context.GetSystemService(Context.InputMethodService); imm.HideSoftInputFromWindow(etBackupPath.WindowToken, 0); etBackupPath.ClearFocus(); e.Handled = true; } }; backupPathToolbar = view.FindViewById<Toolbar>(Resource.Id.backup_path_toolbar); backupPathToolbar.InflateMenu(Resource.Menu.toolbar_backup_path_menu); backupPathToolbar.MenuItemClick += (sender, e) => { switch (e.Item.ItemId) { case Resource.Id.toolbar_backup_path_menu_up: OnBackPressedFragment(); break; case Resource.Id.toolbar_backup_path_menu_home: Refresh(Pref.BackupPath); break; case Resource.Id.toolbar_backup_path_menu_restore: Show(Restore()); break; } }; fab = view.FindViewById<FloatingActionButton>(Resource.Id.fab); fab.Click += (sender, e) => { Show(Backup()); }; return view; }