Ejemplo n.º 1
0
 /// <summary>The delete extended attribute.</summary>
 /// <param name="path">The local path.</param>
 /// <exception cref="ArgumentNullException"> if <paramref name="path"/> is null. </exception>
 public void Delete(string path)
 {
     if (path == null)
     {
         throw new ArgumentNullException(nameof(path));
     }
     NSFileManagerHelper.DeleteExtendedAttribute(path, ExtendedAttributeStorage.ExtendedAttributeKey);
 }
Ejemplo n.º 2
0
        /// <summary>The get file extended attribute.</summary>
        /// <param name="path">The local path.</param>
        /// <returns>The <see cref="ExtendedAttribute"/>.</returns>
        /// <exception cref="ArgumentNullException"> if <paramref name="path"/> is null. </exception>
        /// <exception cref="SerializationException"> if deserializing is failed. </exception>
        public ExtendedAttribute Get(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            byte[] extendedAttribute = NSFileManagerHelper.GetExtendedAttributeBytes(path, ExtendedAttributeKey);
            if (extendedAttribute == null)
            {
                return(null);
            }

            using (MemoryStream stream = new MemoryStream(extendedAttribute))
            {
                return((ExtendedAttribute)this._attributeFormatter.Deserialize(stream));
            }
        }
Ejemplo n.º 3
0
        /// <summary>Write extended attribute.</summary>
        /// <param name="path">The path.</param>
        /// <param name="extendedAttribute">The file extended attribute.</param>
        /// <exception cref="ArgumentNullException"> if <paramref name="path"/> is null. </exception>
        /// <exception cref="ArgumentNullException"> if <paramref name="extendedAttribute"/> is null. </exception>
        /// <exception cref="SerializationException"> if serializing is failed. </exception>
        public void Write(string path, ExtendedAttribute extendedAttribute)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (extendedAttribute == null)
            {
                throw new ArgumentNullException(nameof(extendedAttribute));
            }

            using (MemoryStream stream = new MemoryStream())
            {
                this._attributeFormatter.Serialize(stream, extendedAttribute);
                stream.Flush();
                stream.Position = 0;
                NSFileManagerHelper.SetExtendedAttributeBytes(path, ExtendedAttributeKey, stream.ToArray());
            }
        }