internal Zongsoft.IO.PathInfo Append(string path, long size, string checksum, DateTimeOffset modifiedTime)
        {
            var items = _items;

            if (items == null)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            Zongsoft.IO.PathInfo info;
            var fullPath = this.GetFullPath(path);
            var url      = _resolver.UrlThunk == null ? null : _resolver.UrlThunk(fullPath);

            if (fullPath.EndsWith("/"))
            {
                info = new Zongsoft.IO.DirectoryInfo(fullPath, null, modifiedTime.LocalDateTime, url);
            }
            else
            {
                byte[] checksumBytes = null;

                if (!string.IsNullOrWhiteSpace(checksum))
                {
                    checksumBytes = Zongsoft.Common.Convert.FromHexString(checksum.Trim('"'), '-');
                }

                info = new Zongsoft.IO.FileInfo(fullPath, size, checksumBytes, null, modifiedTime.LocalDateTime, url);
            }

            items.Add(info);
            return(info);
        }
Esempio n. 2
0
        public FileReportDescriptor(string key, string name, string type, Zongsoft.IO.FileInfo file)
        {
            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }

            this.Key      = string.IsNullOrEmpty(key) ? file.Url : key;
            this.Name     = string.IsNullOrEmpty(name) ? file.Name : name;
            this.Type     = string.IsNullOrEmpty(type) ? System.IO.Path.GetExtension(file.Name).Trim('.') : type;
            this.FilePath = file.Path.FullPath;
            this.Url      = Zongsoft.IO.FileSystem.GetUrl(file.Url);
        }
Esempio n. 3
0
        public FileReportDescriptor(Zongsoft.IO.FileInfo file)
        {
            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }

            this.Key      = HashCode.Combine(file.Url).ToString();
            this.Name     = file.Name;
            this.Type     = System.IO.Path.GetExtension(file.Name).Trim('.');
            this.FilePath = file.Path.FullPath;
            this.Url      = Zongsoft.IO.FileSystem.GetUrl(file.Url);
        }