private void NewVolumeStream() { CurrentStream++; Streams.Add(File.Create(_archiveName + VolumeNumber(CurrentStream + 1))); Streams[CurrentStream].SetLength(_volumeSize); StreamOffsets.Add(CurrentStream, new KeyValuePair <long, long>(0, _volumeSize - 1)); }
private void NewVolumeStream() { CurrentStream++; string newVolumeName = null; int p = _archiveName.LastIndexOf("."); if (p >= 0 && _altNames && (p + 1) == _archiveName.Length - 3) { if (CurrentStream == 0) { newVolumeName = _archiveName; } else { newVolumeName = _archiveName.Substring(0, p + 1) + (CurrentStream > 9 ? (CurrentStream > 99 ? CurrentStream.ToString() : "0" + CurrentStream) : "00" + CurrentStream); } } else { newVolumeName = _archiveName + VolumeNumber(CurrentStream + 1); } Streams.Add(File.Create(newVolumeName)); Streams[CurrentStream].SetLength(_volumeSize); StreamOffsets.Add(CurrentStream, new KeyValuePair <long, long>(0, _volumeSize - 1)); }
/// <summary> /// Initializes a new instance of the InMultiStreamWrapper class. /// </summary> /// <param name="fileName">The archive file name.</param> /// <param name="dispose">Perform Dispose() if requested to.</param> public InMultiStreamWrapper(string fileName, bool dispose) : base(dispose) { string baseName = fileName.Substring(0, fileName.Length - 4); int i = 0; while (File.Exists(fileName)) { Streams.Add(new FileStream(fileName, FileMode.Open)); long length = Streams[i].Length; StreamOffsets.Add(i++, new KeyValuePair <long, long>(StreamLength, StreamLength + length)); StreamLength += length; fileName = baseName + VolumeNumber(i + 1); } }
/// <summary> Initializes a new instance of the InMultiStreamWrapper class.</summary> /// <param name="fileName"> The archive file name.</param> /// <param name="altVolumeNaming"> true to alternate volume naming.</param> /// <param name="zipMultiVolume"> true to zip multi volume.</param> /// <param name="dispose"> Perform Dispose() if requested to.</param> public InMultiStreamWrapper(string fileName, bool altVolumeNaming, bool zipMultiVolume, bool dispose) : base(dispose, zipMultiVolume) { string baseName; string originalName = fileName; long length = 0; int i = 0; zipFormat = zipMultiVolume; if (zipMultiVolume) { baseName = fileName.Substring(0, fileName.Length - 2); while (true) { int j = i + 1; fileName = baseName + (j > 9 ? j.ToString() : "0" + j); if (!File.Exists(fileName)) { break; } Streams.Add(new FileStream(fileName, FileMode.Open, FileAccess.Read)); length = Streams[i].Length; StreamOffsets.Add(i++, new KeyValuePair <long, long>(StreamLength, StreamLength + length)); StreamLength += length; } Streams.Add(new FileStream(originalName, FileMode.Open, FileAccess.Read)); length = Streams[i].Length; StreamOffsets.Add(i++, new KeyValuePair <long, long>(StreamLength, StreamLength + length)); StreamLength += length; } else { baseName = fileName.Substring(0, fileName.Length - 4); while (File.Exists(fileName)) { Streams.Add(new FileStream(fileName, FileMode.Open, FileAccess.Read)); length = Streams[i].Length; StreamOffsets.Add(i++, new KeyValuePair <long, long>(StreamLength, StreamLength + length)); StreamLength += length; fileName = baseName + VolumeNumber(i + (altVolumeNaming ? 0 : 1)); } } }