public Task <MetadataInfo> GetMetadataAsync()
        {
            var metaData = new MetadataInfo
            {
                Path         = _path,
                DisplayName  = _path,
                Id           = System.IO.Path.GetDirectoryName(_path),
                IsFolder     = true,
                LastModified = Directory.GetLastWriteTimeUtc(_path),
                Name         = System.IO.Path.GetDirectoryName(_path)
            };

            return(Task.FromResult(metaData));
        }
Esempio n. 2
0
        public Task <MetadataInfo> GetMetadataAsync()
        {
            string newPath = GetUpdatedPath();

            if (!File.Exists(newPath))
            {
                return(Task.FromResult <MetadataInfo>(null));
            }

            var metaData = new MetadataInfo
            {
                Path         = newPath,
                DisplayName  = newPath,
                Id           = System.IO.Path.GetFileName(newPath),
                IsFolder     = false,
                LastModified = File.GetLastWriteTimeUtc(newPath),
                Name         = System.IO.Path.GetFileName(newPath),
                Size         = File.ReadAllBytes(newPath).Length
            };

            return(Task.FromResult(metaData));
        }
Esempio n. 3
0
        private async Task <string> GetHandleIdFromPathAsync(Uri uri, string[] parts, int idx, MetadataInfo current)
        {
            if (idx == 0 && parts.Length == 0)
            {
                // this is the top most root.
                var itemArray = (await _cdpHelper.SendResultAsync <MetadataInfo[]>(HttpMethod.Get, uri)).Item1;

                if (itemArray != null && itemArray.Length > 0)
                {
                    return(itemArray[0].Id);
                }
                else
                {
                    return(null);
                }
            }

            if (idx >= parts.Length)
            {
                return(current.Id);
            }

            var itemsArray = (await _cdpHelper.SendResultAsync <MetadataInfo[]>(HttpMethod.Get, uri)).Item1;

            if (itemsArray != null)
            {
                foreach (var item in itemsArray)
                {
                    if (item.IsFolder)
                    {
                        if (item.Path == "/")
                        {
                            // This is the root folder
                            return(await GetHandleIdFromPathAsync(_cdpHelper.MakeUri(CdpConstants.FoldersRoot + "/" + item.Id), parts, idx, item));
                        }
                        else if (item.Name.Equals(parts[idx], StringComparison.OrdinalIgnoreCase))
                        {
                            return(await GetHandleIdFromPathAsync(_cdpHelper.MakeUri(CdpConstants.FoldersRoot + "/" + item.Id), parts, ++idx, item));
                        }
                    }
                }
            }

            return(null);
        }