public Task <IFile> CreateFile(string path, byte[] contents) { return(Task.Run <IFile> (() => { var r = new DeviceFile(path, documentsPath); if (contents != null) { Directory.CreateDirectory(Path.GetDirectoryName(r.LocalPath)); File.WriteAllBytes(r.LocalPath, contents); } return r; })); }
public Task <IFile> CreateFile(string path, byte[] contents) { return(Task.Run <IFile> (() => { var r = new DeviceFile(path, documentsPath); if (contents != null) { var dir = Path.GetDirectoryName(r.LocalPath); if (!Directory.Exists(dir)) { if (File.Exists(dir)) { File.Delete(dir); } Directory.CreateDirectory(dir); } File.WriteAllBytes(r.LocalPath, contents); } return r; })); }
void ReadQueryResults() { var fm = new NSFileManager(); var deadIndex = new HashSet <string> (fileIndex.Keys); var newList = new List <CloudFile> (); var newIndex = new Dictionary <string, IFile> (); // Console.WriteLine ("-------------- Received iCloud"); foreach (var item in query.Results) { var cf = new CloudFile(item, documentsUrl); var key = cf.Path; if (deadIndex.Contains(key)) { deadIndex.Remove(key); } else { newList.Add(cf); } newIndex[key] = cf; // // Add a "file" for directories // var dir = Path.GetDirectoryName(cf.Path); if (!string.IsNullOrEmpty(dir) && !newIndex.ContainsKey(dir)) { newIndex [dir] = new DeviceFile(dir, documentsUrl.Path); } // Console.WriteLine (cf); } foreach (var f in newList) { if (!f.IsDownloaded) { NSError error; fm.StartDownloadingUbiquitous(f.LocalUrl, out error); } } fileIndex = newIndex; IsSyncing = false; if (firstQueryResult != null) { var t = firstQueryResult; firstQueryResult = null; t.SetResult(null); } var ev = FilesChanged; if (ev != null) { ev(this, EventArgs.Empty); } }
#pragma warning restore 67 public Task <IFile> GetFile(string path) { var file = new DeviceFile(path, documentsPath); return(Task.FromResult <IFile> (file)); }
void ReadQueryResults () { var fm = new NSFileManager (); var deadIndex = new HashSet<string> (fileIndex.Keys); var newList = new List<CloudFile> (); var newIndex = new Dictionary<string, IFile> (); // Console.WriteLine ("-------------- Received iCloud"); foreach (var item in query.Results) { var cf = new CloudFile (item, documentsUrl); var key = cf.Path; if (deadIndex.Contains (key)) { deadIndex.Remove (key); } else { newList.Add (cf); } newIndex[key] = cf; // // Add a "file" for directories // var dir = Path.GetDirectoryName (cf.Path); if (!string.IsNullOrEmpty (dir) && !newIndex.ContainsKey (dir)) newIndex [dir] = new DeviceFile (dir, documentsUrl.Path); // Console.WriteLine (cf); } foreach (var f in newList) { if (!f.IsDownloaded) { NSError error; fm.StartDownloadingUbiquitous (f.LocalUrl, out error); } } fileIndex = newIndex; IsSyncing = false; if (firstQueryResult != null) { var t = firstQueryResult; firstQueryResult = null; t.SetResult (null); } var ev = FilesChanged; if (ev != null) { ev (this, EventArgs.Empty); } }
public Task<IFile> GetFile (string path) { var file = new DeviceFile (path, documentsPath); return Task.FromResult<IFile> (file); }
public Task<IFile> CreateFile (string path, byte[] contents) { return Task.Run<IFile> (() => { var r = new DeviceFile (path, documentsPath); if (contents != null) { Directory.CreateDirectory (Path.GetDirectoryName (r.LocalPath)); File.WriteAllBytes (r.LocalPath, contents); } return r; }); }