public bool Create(string path, MediaType mediaType, Dictionary <string, string> options, ulong sectors, uint sectorSize) { if (options != null) { if (options.TryGetValue("separate", out string tmpValue)) { if (!bool.TryParse(tmpValue, out separateTracksWriting)) { ErrorMessage = "Invalid value for split option"; return(false); } if (separateTracksWriting) { ErrorMessage = "Separate tracksnot yet implemented"; return(false); } } } else { separateTracksWriting = false; } if (!SupportedMediaTypes.Contains(mediaType)) { ErrorMessage = $"Unsupport media format {mediaType}"; return(false); } imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors }; // TODO: Separate tracks try { writingBaseName = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path)); descriptorStream = new StreamWriter(path, false, Encoding.ASCII); } catch (IOException e) { ErrorMessage = $"Could not create new image file, exception {e.Message}"; return(false); } discimage = new CdrWinDisc { Disktype = mediaType, Sessions = new List <Session>(), Tracks = new List <CdrWinTrack>() }; trackFlags = new Dictionary <byte, byte>(); trackIsrcs = new Dictionary <byte, string>(); IsWriting = true; ErrorMessage = null; return(true); }
public bool Create(string path, MediaType mediaType, Dictionary <string, string> options, ulong sectors, uint sectorSize) { if (options != null) { if (options.TryGetValue("separate", out string tmpValue)) { if (!bool.TryParse(tmpValue, out _separateTracksWriting)) { ErrorMessage = "Invalid value for split option"; return(false); } if (_separateTracksWriting) { ErrorMessage = "Separate tracks not yet implemented"; return(false); } } } else { _separateTracksWriting = false; } if (!SupportedMediaTypes.Contains(mediaType)) { ErrorMessage = $"Unsupported media format {mediaType}"; return(false); } _imageInfo = new ImageInfo { MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors }; // TODO: Separate tracks try { _writingBaseName = Path.Combine(Path.GetDirectoryName(path) ?? "", Path.GetFileNameWithoutExtension(path)); _descriptorStream = new StreamWriter(path, false, Encoding.ASCII); } catch (IOException e) { ErrorMessage = $"Could not create new image file, exception {e.Message}"; return(false); } _discImage = new CdrWinDisc { MediaType = mediaType, Sessions = new List <Session>(), Tracks = new List <CdrWinTrack>() }; int mediaTypeAsInt = (int)_discImage.MediaType; _isCd = (mediaTypeAsInt >= 10 && mediaTypeAsInt <= 39) || mediaTypeAsInt == 112 || mediaTypeAsInt == 113 || (mediaTypeAsInt >= 150 && mediaTypeAsInt <= 152) || mediaTypeAsInt == 154 || mediaTypeAsInt == 155 || (mediaTypeAsInt >= 171 && mediaTypeAsInt <= 179) || (mediaTypeAsInt >= 740 && mediaTypeAsInt <= 749); if (_isCd) { _trackFlags = new Dictionary <byte, byte>(); _trackIsrcs = new Dictionary <byte, string>(); } IsWriting = true; ErrorMessage = null; return(true); }