Exemple #1
0
        /* ----------------------------------------------------------------- */
        ///
        /// CreateDirectory
        ///
        /// <summary>
        /// Creates the directory.
        /// </summary>
        ///
        /// <param name="src">Information of the archived item.</param>
        /// <param name="root">Path of the root directory.</param>
        ///
        /* ----------------------------------------------------------------- */
        public static void CreateDirectory(this ArchiveEntity src, string root)
        {
            if (!src.IsDirectory)
            {
                return;
            }
            var path = Io.Combine(root, src.FullName);

            Io.CreateDirectory(path);
            SetAttributes(src, root);
        }
Exemple #2
0
        /* ----------------------------------------------------------------- */
        ///
        /// SetLastAccessTime
        ///
        /// <summary>
        /// Sets the last accessed time.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private static void SetLastAccessTime(ArchiveEntity src, string path)
        {
            var time = src.LastAccessTime != DateTime.MinValue ? src.LastAccessTime :
                       src.LastWriteTime != DateTime.MinValue ? src.LastWriteTime :
                       src.CreationTime;

            if (time != DateTime.MinValue)
            {
                Io.SetLastAccessTime(path, time);
            }
        }
Exemple #3
0
        /* ----------------------------------------------------------------- */
        ///
        /// SetAttributes
        ///
        /// <summary>
        /// Sets attributes, creation time, last written time, and last
        /// accessed time to the extracted file or directory.
        /// </summary>
        ///
        /// <param name="src">Information of the archived item.</param>
        /// <param name="root">Path of the root directory.</param>
        ///
        /* ----------------------------------------------------------------- */
        public static void SetAttributes(this ArchiveEntity src, string root)
        {
            var path = Io.Combine(root, src.FullName);

            if (!Io.Exists(path))
            {
                return;
            }

            SetCreationTime(src, path);
            SetLastWriteTime(src, path);
            SetLastAccessTime(src, path);
            Io.SetAttributes(path, src.Attributes);
        }
Exemple #4
0
 /* ----------------------------------------------------------------- */
 ///
 /// Save
 ///
 /// <summary>
 /// Extracts the specified item and saves them in the specified
 /// directory.
 /// </summary>
 ///
 /// <param name="src">Source reader object.</param>
 /// <param name="dest">
 /// Path of the directory to save. If the parameter is set to null
 /// or empty, the method invokes as a test mode.
 /// </param>
 /// <param name="item">Archived item to extract.</param>
 /// <param name="progress">Progress object.</param>
 ///
 /* ----------------------------------------------------------------- */
 public static void Save(this ArchiveReader src,
                         string dest, ArchiveEntity item, IProgress <Report> progress) =>
 src.Save(dest, new[] { (uint)item.Index }, progress);
Exemple #5
0
 /* ----------------------------------------------------------------- */
 ///
 /// Save
 ///
 /// <summary>
 /// Extracts the specified item and saves them in the specified
 /// directory.
 /// </summary>
 ///
 /// <param name="src">Source reader object.</param>
 /// <param name="dest">
 /// Path of the directory to save. If the parameter is set to null
 /// or empty, the method invokes as a test mode.
 /// </param>
 /// <param name="item">Archived item to extract.</param>
 ///
 /* ----------------------------------------------------------------- */
 public static void Save(this ArchiveReader src, string dest, ArchiveEntity item) =>
 src.Save(dest, item, null);