public IEnumerable <Entry> Search(string path, bool recursive = false) { try { // If the path is not absolute let's rebase it on ddbPath if (path != null && !Path.IsPathRooted(path)) { path = Path.Combine(DatasetFolderPath, path); } // If path is null we use the base ddb path path ??= DatasetFolderPath; var entries = DDBWrapper.List(DatasetFolderPath, path, recursive); if (entries == null) { Debug.WriteLine("Strange null return value"); return(Array.Empty <Entry>()); } return(entries); } catch (DDBException ex) { throw new InvalidOperationException($"Cannot list '{path}' to ddb '{DatasetFolderPath}'", ex); } }
static DDB() { #if DEBUG DDBWrapper.RegisterProcess(true); #else DDBWrapper.RegisterProcess(false); #endif }
public bool IsBuildPending() { try { return(DDBWrapper.IsBuildPending(DatasetFolderPath)); } catch (DDBException ex) { throw new InvalidOperationException($"Cannot call IsBuildPending from ddb '{DatasetFolderPath}'", ex); } }
public Dictionary <string, object> ChangeAttributesRaw(Dictionary <string, object> attributes) { try { return(DDBWrapper.ChangeAttributes(DatasetFolderPath, attributes)); } catch (DDBException ex) { throw new InvalidOperationException($"Cannot change attributes of ddb '{DatasetFolderPath}'", ex); } }
public Meta Set(string key, string data, string path = null) { var m = DDBWrapper.MetaSet(_ddb.DatasetFolderPath, key, data, path); return(new Meta { Data = JToken.FromObject(m.Data), Id = m.Id, ModifiedTime = m.ModifiedTime }); }
public void AddRaw(string path) { try { DDBWrapper.Add(DatasetFolderPath, path); } catch (DDBException ex) { throw new InvalidOperationException($"Cannot add '{path}' to ddb '{DatasetFolderPath}'", ex); } }
public void BuildPending(string dest = null, bool force = false) { try { DDBWrapper.Build(DatasetFolderPath, null, dest, force, true); } catch (DDBException ex) { throw new InvalidOperationException($"Cannot build pending from ddb '{DatasetFolderPath}'", ex); } }
public void Init() { try { var res = DDBWrapper.Init(DatasetFolderPath); Debug.WriteLine(res); } catch (DDBException ex) { throw new InvalidOperationException($"Cannot initialize ddb in folder '{DatasetFolderPath}'", ex); } }
public byte[] GenerateTile(string inputPath, int tz, int tx, int ty, bool retina, string inputPathHash) { try { return(DDBWrapper.GenerateMemoryTile(inputPath, tz, tx, ty, retina ? 512 : 256, true, false, inputPathHash)); } catch (DDBException ex) { throw new InvalidOperationException($"Cannot generate tile of '{inputPath}'", ex); } }
public byte[] GenerateThumbnail(string imagePath, int size) { try { return(DDBWrapper.GenerateThumbnail(imagePath, size)); } catch (DDBException ex) { throw new InvalidOperationException( $"Cannot generate thumbnail of '{imagePath}' with size '{size}'", ex); } }
public void Move(string source, string dest) { try { DDBWrapper.MoveEntry(DatasetFolderPath, source, dest); } catch (DDBException ex) { throw new InvalidOperationException($"Cannot move '{source}' to {dest} from ddb '{DatasetFolderPath}'", ex); } }
public void Remove(string path) { try { // If the path is not absolute let's rebase it on ddbPath if (!Path.IsPathRooted(path)) { path = Path.Combine(DatasetFolderPath, path); } DDBWrapper.Remove(DatasetFolderPath, path); } catch (DDBException ex) { throw new InvalidOperationException($"Cannot remove '{path}' from ddb '{DatasetFolderPath}'", ex); } }
public Entry GetInfo(string path) { if (string.IsNullOrWhiteSpace(path)) { throw new ArgumentException("Path cannot be null or empty"); } var info = DDBWrapper.Info(DatasetFolderPath); var entry = info.FirstOrDefault(); if (entry == null) { throw new InvalidOperationException("Cannot get ddb info of dataset"); } return(entry); }
public int Unset(string key, string path = null) { return(DDBWrapper.MetaUnset(_ddb.DatasetFolderPath, key, path)); }
public long GetSize() { return(DDBWrapper.Info(DatasetFolderPath).FirstOrDefault()?.Size ?? 0); }
public Stamp GetStamp() { return(DDBWrapper.GetStamp(DatasetFolderPath)); }
public void Add(string path, Stream stream = null) { if (stream == null) { string folderPath = null; try { folderPath = Path.Combine(DatasetFolderPath, path); Directory.CreateDirectory(folderPath); DDBWrapper.Add(DatasetFolderPath, folderPath); } catch (DDBException ex) { throw new InvalidOperationException($"Cannot add folder '{path}' to ddb '{DatasetFolderPath}'", ex); } finally { if (folderPath != null && Directory.Exists(folderPath)) { if (!CommonUtils.SafeDeleteFolder(folderPath)) { Debug.WriteLine($"Cannot delete folder '{folderPath}'"); } } } } else { string filePath = null; try { filePath = Path.Combine(DatasetFolderPath, path); stream.SafeReset(); CommonUtils.EnsureSafePath(filePath); using (var writer = File.OpenWrite(filePath)) { stream.CopyTo(writer); } DDBWrapper.Add(DatasetFolderPath, filePath); } catch (DDBException ex) { throw new InvalidOperationException($"Cannot add '{path}' to ddb '{DatasetFolderPath}'", ex); } finally { if (filePath != null && File.Exists(filePath)) { if (!CommonUtils.SafeDelete(filePath)) { Debug.WriteLine($"Cannot delete file '{filePath}'"); } } } } }
public MetaListItem[] List(string path = null) { return(DDBWrapper.MetaList(_ddb.DatasetFolderPath, path).ToArray()); }
public int Remove(string id) { return(DDBWrapper.MetaRemove(_ddb.DatasetFolderPath, id)); }
public string Get(string key, string path = null) { var m = DDBWrapper.MetaGet(_ddb.DatasetFolderPath, key, path); return(m); }
public MetaDump[] Dump(string ids = null) { return(DDBWrapper.MetaDump(_ddb.DatasetFolderPath, ids).ToArray()); }