Ejemplo n.º 1
0
        /// <summary>The update file data except content.</summary>
        /// <param name="localFile">The local file.</param>
        /// <returns>The <see cref="LocalFile"/>.</returns>
        /// <exception cref="ArgumentNullException"> if <paramref name="localFile"/> is null. </exception>
        public LocalFile UpdateFile(LocalFile localFile)
        {
            if (localFile == null)
            {
                throw new ArgumentNullException(nameof(localFile));
            }
            if (NSFileManager.DefaultManager.FileExists(localFile.Path))
            {
                this.extendedAttributeStorage.Write(localFile.Path, localFile.ExtendedAttribute);
            }

            return(this.GetFile(localFile.Path));
        }
Ejemplo n.º 2
0
        /// <summary>Returns <see cref="LocalFile"/> for provided path.</summary>
        /// <param name="path">The local path.</param>
        /// <param name="isExists">The value indicating whether is item exists. </param>
        /// <returns>The <see cref="LocalFile"/>.</returns>
        /// <exception cref="ArgumentNullException"> if <paramref name="path"/> is null. </exception>
        private LocalFile GetFile(string path, bool isExists)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            if (!isExists)
            {
                return(LocalFile.CreateNotExist(path));
            }
            ulong fileSize = NSFileManager.DefaultManager.GetAttributes(path).Size.GetValueOrDefault();

            try
            {
                ExtendedAttribute extendedAttribute = this.extendedAttributeStorage.Get(path);
                return(LocalFile.CreateExists(path, fileSize, extendedAttribute));
            }
            catch (SerializationException)
            {
                this.extendedAttributeStorage.Delete(path);
                return(LocalFile.CreateExists(path, fileSize));
            }
        }