Beispiel #1
0
        /// <summary>
        /// Adds an annotation to <paramref name="path"/>
        /// </summary>
        /// <param name="path"></param>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public void Annotate(string path, string key, string value)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }
            else if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException("key");
            }

            DirectoryMapItem item = GetFile(path);

            if (item == null)
            {
                return; // TODO: Add directory support?
            }
            if (item.Annotations.Contains(key))
            {
                if (value != null)
                {
                    item.Annotations[key].Value = value;
                }
                else
                {
                    item.Annotations.Remove(key);
                }
            }
            else if (value != null)
            {
                item.Annotations.Add(new DirectoryMapAnnotation(key, value));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gets the annotation.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        public string GetAnnotation(string path, string key)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }
            else if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException("key");
            }

            DirectoryMapItem item = GetFile(path);

            if (item == null)
            {
                return(null); // TODO: Add directory support?
            }
            if (item.Annotations.Contains(key))
            {
                return(item.Annotations[key].Value);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DirectoryMapStream"/> class.
        /// </summary>
        /// <param name="parentStream">The parent stream.</param>
        /// <param name="file">The file.</param>
        /// <param name="mode">The mode.</param>
        /// <param name="hash">The hash.</param>
        /// <param name="size">The size.</param>
        /// <param name="hashType">Type of the hash.</param>
        internal DirectoryMapStream(Stream parentStream, DirectoryMapFile file, FileMode mode, string hash, long size, HashType hashType)
            : base(parentStream, true, UseAsync(mode, hash))
        {
            if (mode == FileMode.Create || mode == FileMode.CreateNew)
            {
                _newHash       = hash;
                _updateOnClose = true;

                if (string.IsNullOrEmpty(hash))
                {
                    _hashOnClose      = true;
                    _hashWhileWriting = true;
                }
            }

            _hashType = hashType;
            _file     = file;
            _size     = size;
        }
Beispiel #4
0
 public Initializer(DirectoryMapItem file)
 {
     _file = file;
     _file.BeginInit();
 }