Exemplo n.º 1
0
        /// <summary>
        /// Gets a value indicating whether the specified catalog entry already exists.
        /// </summary>
        /// <param name="entry">The catalog entry.</param>
        /// <returns><c>true</c> if the catalog entry exists. Otherwise <c>false.</c></returns>
        public async Task <bool> CatalogEntryExists(CatalogEntry entry)
        {
            return(await Task.Run(() =>
            {
                entry.ValidatePath();

                string path = entry.GeneratePath();

                return File.Exists(path);
            }));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the catalog entry by the initial instance set.
        /// </summary>
        /// <param name="entry">The initial catalog entry set.</param>
        /// <returns>The instance of <see cref="CatalogEntry"/> type.</returns>
        public async Task <CatalogEntry> GetCatalogEntry(CatalogEntry entry)
        {
            return(await Task.Run(() =>
            {
                entry.ValidatePath();

                entry.Path = entry.GeneratePath();
                if (File.Exists(entry.Path))
                {
                    entry.Size = new FileInfo(entry.Path).Length;
                }

                return entry;
            }));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Deletes the specified catalog entry.
        /// </summary>
        /// <param name="entry">The instance of <see cref="CatalogEntry" /> type to delete.</param>
        /// <returns>
        /// The deleted instance of <see cref="CatalogEntry"/> type.
        /// </returns>
        public async Task <CatalogEntry> DeleteCatalogEntry(CatalogEntry entry)
        {
            return(await Task.Run(() =>
            {
                entry.ValidatePath();

                entry.Path = entry.GeneratePath();
                if (File.Exists(entry.Path))
                {
                    lock (FileAccessSyncObject)
                    {
                        if (File.Exists(entry.Path))
                        {
                            File.Delete(entry.Path);
                        }
                    }
                }

                return entry;
            }));
        }