コード例 #1
0
        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);
            }
        }
コード例 #2
0
        static DDB()
        {
#if DEBUG
            DDBWrapper.RegisterProcess(true);
#else
            DDBWrapper.RegisterProcess(false);
#endif
        }
コード例 #3
0
 public bool IsBuildPending()
 {
     try
     {
         return(DDBWrapper.IsBuildPending(DatasetFolderPath));
     }
     catch (DDBException ex)
     {
         throw new InvalidOperationException($"Cannot call IsBuildPending from ddb '{DatasetFolderPath}'", ex);
     }
 }
コード例 #4
0
 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);
     }
 }
コード例 #5
0
        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
            });
        }
コード例 #6
0
 public void AddRaw(string path)
 {
     try
     {
         DDBWrapper.Add(DatasetFolderPath, path);
     }
     catch (DDBException ex)
     {
         throw new InvalidOperationException($"Cannot add '{path}' to ddb '{DatasetFolderPath}'", ex);
     }
 }
コード例 #7
0
 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);
     }
 }
コード例 #8
0
 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);
     }
 }
コード例 #9
0
 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);
     }
 }
コード例 #10
0
 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);
     }
 }
コード例 #11
0
 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);
     }
 }
コード例 #12
0
        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);
            }
        }
コード例 #13
0
        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);
        }
コード例 #14
0
 public int Unset(string key, string path = null)
 {
     return(DDBWrapper.MetaUnset(_ddb.DatasetFolderPath, key, path));
 }
コード例 #15
0
 public long GetSize()
 {
     return(DDBWrapper.Info(DatasetFolderPath).FirstOrDefault()?.Size ?? 0);
 }
コード例 #16
0
 public Stamp GetStamp()
 {
     return(DDBWrapper.GetStamp(DatasetFolderPath));
 }
コード例 #17
0
        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}'");
                        }
                    }
                }
            }
        }
コード例 #18
0
 public MetaListItem[] List(string path = null)
 {
     return(DDBWrapper.MetaList(_ddb.DatasetFolderPath, path).ToArray());
 }
コード例 #19
0
 public int Remove(string id)
 {
     return(DDBWrapper.MetaRemove(_ddb.DatasetFolderPath, id));
 }
コード例 #20
0
        public string Get(string key, string path = null)
        {
            var m = DDBWrapper.MetaGet(_ddb.DatasetFolderPath, key, path);

            return(m);
        }
コード例 #21
0
 public MetaDump[] Dump(string ids = null)
 {
     return(DDBWrapper.MetaDump(_ddb.DatasetFolderPath, ids).ToArray());
 }