/// <summary> /// Make a new <see cref="ZipEntry"></see> for a directory. /// </summary> /// <param name="directoryName">The raw untransformed name for the new directory</param> /// <param name="useFileSystem">If true entry detail is retrieved from the file system if the file exists.</param> /// <returns>Returns a new <see cref="ZipEntry"></see> representing a directory.</returns> public ZipEntry MakeDirectoryEntry(string directoryName, bool useFileSystem) { var result = new ZipEntry(nameTransform_.TransformDirectory(directoryName)){Size = 0}; var externalAttributes = 0; DirectoryInfo di = null; if (useFileSystem) { di = new DirectoryInfo(directoryName); } if ((di != null) && di.Exists) { switch (timeSetting_) { case TimeSetting.CreateTime: result.DateTime = di.CreationTime; break; //case TimeSetting.CreateTimeUtc: //result.DateTime = di.CreationTimeUtc; //break; case TimeSetting.LastAccessTime: result.DateTime = di.LastAccessTime; break; //case TimeSetting.LastAccessTimeUtc: //result.DateTime = di.LastAccessTimeUtc; //break; case TimeSetting.LastWriteTime: result.DateTime = di.LastWriteTime; break; //case TimeSetting.LastWriteTimeUtc: //result.DateTime = di.LastWriteTimeUtc; //break; case TimeSetting.Fixed: result.DateTime = fixedDateTime_; break; default: throw new ZipException("Unhandled time setting in MakeDirectoryEntry"); } externalAttributes = ((int)di.Attributes & getAttributes_); } else { if (timeSetting_ == TimeSetting.Fixed) { result.DateTime = fixedDateTime_; } } // Always set directory attribute on. externalAttributes |= (setAttributes_ | 16); result.ExternalFileAttributes = externalAttributes; return result; }
/// <summary> /// Make a new <see cref="ZipEntry"></see> for a directory. /// </summary> /// <param name="directoryName">The raw untransformed name for the new directory</param> /// <param name="useFileSystem">If true entry detail is retrieved from the file system if the file exists.</param> /// <returns>Returns a new <see cref="ZipEntry"></see> representing a directory.</returns> public ZipEntry MakeDirectoryEntry(string directoryName, bool useFileSystem) { var result = new ZipEntry(nameTransform_.TransformDirectory(directoryName)) { Size = 0 }; var externalAttributes = 0; DirectoryInfo di = null; if (useFileSystem) { di = new DirectoryInfo(directoryName); } if ((di != null) && di.Exists) { switch (timeSetting_) { case TimeSetting.CreateTime: result.DateTime = di.CreationTime; break; //case TimeSetting.CreateTimeUtc: //result.DateTime = di.CreationTimeUtc; //break; case TimeSetting.LastAccessTime: result.DateTime = di.LastAccessTime; break; //case TimeSetting.LastAccessTimeUtc: //result.DateTime = di.LastAccessTimeUtc; //break; case TimeSetting.LastWriteTime: result.DateTime = di.LastWriteTime; break; //case TimeSetting.LastWriteTimeUtc: //result.DateTime = di.LastWriteTimeUtc; //break; case TimeSetting.Fixed: result.DateTime = fixedDateTime_; break; default: throw new ZipException("Unhandled time setting in MakeDirectoryEntry"); } externalAttributes = ((int)di.Attributes & getAttributes_); } else { if (timeSetting_ == TimeSetting.Fixed) { result.DateTime = fixedDateTime_; } } // Always set directory attribute on. externalAttributes |= (setAttributes_ | 16); result.ExternalFileAttributes = externalAttributes; return(result); }
/// <summary> /// Make a new <see cref="ZipEntry"/> from a name. /// </summary> /// <param name="fileName">The name of the file to create a new entry for.</param> /// <param name="useFileSystem">If true entry detail is retrieved from the file system if the file exists.</param> /// <returns>Returns a new <see cref="ZipEntry"/> based on the <paramref name="fileName"/>.</returns> public ZipEntry MakeFileEntry(string fileName, bool useFileSystem) { var result = new ZipEntry(nameTransform_.TransformFile(fileName)){IsUnicodeText = isUnicodeText_}; var externalAttributes = 0; var useAttributes = (setAttributes_ != 0); FileInfo fi = null; if (useFileSystem) { fi = new FileInfo(fileName); } if ((fi != null) && fi.Exists) { switch (timeSetting_) { case TimeSetting.CreateTime: result.DateTime = fi.CreationTime; break; //case TimeSetting.CreateTimeUtc: //result.DateTime = fi.CreationTimeUtc; //break; case TimeSetting.LastAccessTime: result.DateTime = fi.LastAccessTime; break; //case TimeSetting.LastAccessTimeUtc: //result.DateTime = fi.LastAccessTimeUtc; //break; case TimeSetting.LastWriteTime: result.DateTime = fi.LastWriteTime; break; //case TimeSetting.LastWriteTimeUtc: //result.DateTime = fi.LastWriteTimeUtc; //break; case TimeSetting.Fixed: result.DateTime = fixedDateTime_; break; default: throw new ZipException("Unhandled time setting in MakeFileEntry"); } result.Size = fi.Length; useAttributes = true; externalAttributes = ((int)fi.Attributes & getAttributes_); } else { if (timeSetting_ == TimeSetting.Fixed) { result.DateTime = fixedDateTime_; } } if (useAttributes) { externalAttributes |= setAttributes_; result.ExternalFileAttributes = externalAttributes; } return result; }
/// <summary> /// Make a new <see cref="ZipEntry"/> from a name. /// </summary> /// <param name="fileName">The name of the file to create a new entry for.</param> /// <param name="useFileSystem">If true entry detail is retrieved from the file system if the file exists.</param> /// <returns>Returns a new <see cref="ZipEntry"/> based on the <paramref name="fileName"/>.</returns> public ZipEntry MakeFileEntry(string fileName, bool useFileSystem) { var result = new ZipEntry(nameTransform_.TransformFile(fileName)) { IsUnicodeText = isUnicodeText_ }; var externalAttributes = 0; var useAttributes = (setAttributes_ != 0); FileInfo fi = null; if (useFileSystem) { fi = new FileInfo(fileName); } if ((fi != null) && fi.Exists) { switch (timeSetting_) { case TimeSetting.CreateTime: result.DateTime = fi.CreationTime; break; //case TimeSetting.CreateTimeUtc: //result.DateTime = fi.CreationTimeUtc; //break; case TimeSetting.LastAccessTime: result.DateTime = fi.LastAccessTime; break; //case TimeSetting.LastAccessTimeUtc: //result.DateTime = fi.LastAccessTimeUtc; //break; case TimeSetting.LastWriteTime: result.DateTime = fi.LastWriteTime; break; //case TimeSetting.LastWriteTimeUtc: //result.DateTime = fi.LastWriteTimeUtc; //break; case TimeSetting.Fixed: result.DateTime = fixedDateTime_; break; default: throw new ZipException("Unhandled time setting in MakeFileEntry"); } result.Size = fi.Length; useAttributes = true; externalAttributes = ((int)fi.Attributes & getAttributes_); } else { if (timeSetting_ == TimeSetting.Fixed) { result.DateTime = fixedDateTime_; } } if (useAttributes) { externalAttributes |= setAttributes_; result.ExternalFileAttributes = externalAttributes; } return(result); }