/// <summary>Associate the FITS object with a file or URL. /// * /// The string is assumed to be a URL if it begins with /// http: otherwise it is treated as a file name. /// If the string ends in .gz it is assumed that /// the data is in a compressed format. /// All string comparisons are case insensitive. /// * /// </summary> /// <param name="filename">The name of the file or URL to be processed.</param> /// <exception cref=""> FitsException Thrown if unable to find or open /// a file or URL from the string given.</exception> public Fits(String filename) { InitBlock(); //Stream inp; if (filename == null) { throw new FitsException("Null FITS Identifier String"); } bool compressed = FitsUtil.IsCompressed(filename); int len = filename.Length; if (len > 4 && filename.Substring(0, (5) - (0)).ToUpper().Equals("http:".ToUpper())) { // This seems to be a URL. System.Uri myURL; try { //UPGRADE_TODO: Class 'java.net.URL' was converted to a 'System.Uri' which does not throw an exception if a URL specifies an unknown protocol. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1132"' myURL = new Uri(filename); } catch (IOException) { throw new FitsException("Unable to convert string to URL: " + filename); } try { Stream is_Renamed = System.Net.WebRequest.Create(myURL).GetResponse().GetResponseStream(); streamInit(is_Renamed, compressed, false); } catch (IOException e) { throw new FitsException("Unable to open stream from URL:" + filename + " Exception=" + e); } } else if (compressed) { fileInit(new FileInfo(filename), true); } else { randomInit(filename); } }
/// <summary>Associate the FITS object with a given uncompressed URL</summary> /// <param name="myURL">The URL to be associated with the FITS file.</param> /// <exception cref="FitsException">Thrown if unable to use the specified URL.</exception> public Fits(Uri myURL) : this(myURL, FitsUtil.IsCompressed(myURL.AbsoluteUri)) { }
/// <summary> /// Asscoiates a fits object with a file specified by the Fileaccess parameter /// </summary> /// <param name="filename"></param> /// <param name="access"></param> public Fits(String filename, FileAccess access) : this(filename, FitsUtil.IsCompressed(filename), access) { InitBlock(); }
/// <summary>Associate the FITS object with a file or URL. /// * /// The string is assumed to be a URL if it begins one of the /// protocol strings. /// If the string ends in .gz it is assumed that /// the data is in a compressed format. /// All string comparisons are case insensitive. /// * /// </summary> /// <param name="filename">The name of the file or URL to be processed.</param> /// <exception cref=""> FitsException Thrown if unable to find or open /// a file or URL from the string given.</exception> public Fits(String filename) : this(filename, FitsUtil.IsCompressed(filename), FileAccess.ReadWrite) { InitBlock(); }
/// <summary>Associate the FITS object with a given uncompressed URL</summary> /// <param name="myURL">The URL to be associated with the FITS file.</param> /// <exception cref="">FitsException Thrown if unable to use the specified URL.</exception> public Fits(Uri myURL) : this(myURL, FitsUtil.IsCompressed(myURL.AbsolutePath)) { InitBlock(); }