public static string GetDirectoryPath(JsonStructureManager jsonStructureManager, int id)
        {
            var pathList = new List <string>();

            if (id > 0)
            {
                int did = id;
                while (did > 0)
                {
                    var dir = jsonStructureManager.GetDirectoryStructure(did);

                    pathList.Add(dir.Name);
                    var parent = dir.Parent;
                    did = parent;
                }

                var path = new StringBuilder();
                pathList.Reverse();
                foreach (var pathItem in pathList)
                {
                    path.AppendFormat("/{0}", pathItem);
                }
                return(path.ToString());
            }
            else
            {
                return("/");
            }
        }
        public void Dispose()
        {
            Save();
            fManager?.Dispose();

            fManager             = null;
            jsonStructureManager = null;
        }
        public static string GetFilePath(JsonStructureManager jsonStructureManager, int id)
        {
            var file     = jsonStructureManager.GetFileStructure(id);
            var fileName = file.Name;
            var parent   = file.Parent;

            string dirPath = GetDirectoryPath(jsonStructureManager, parent);

            if (!dirPath.Equals("/"))
            {
                return("{0}/{1}".FormatString(dirPath, fileName));
            }
            return("/{0}".FormatString(fileName));
        }
        protected AbstractJsonResourceManager(string filePath, bool newFile = false, bool isCheckHash = true)
        {
            if (newFile)
            {
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
            }

            fManager = new DatFileManager(filePath)
            {
                IsShiftJsonPosition = true
            };
            var json = newFile ? string.Empty : Encoding.UTF8.GetString(fManager.GetBytesFromEnd(JSON_LEN));

            jsonStructureManager = new JsonStructureManager(json, isCheckHash);
            fManager.IsCheckHash = jsonStructureManager.IsCheckHash;
            FilePath             = filePath;
        }