Beispiel #1
0
        /// <summary>
        /// Creates an output file stream to write to the file with the specified
        /// <code>name</code>.  If the second argument is <code>true</code>, then
        /// bytes will be written to the end of the file rather than the beginning.
        /// A new <code>OWFileDescriptor</code> object is created to represent this
        /// file connection.
        /// <para>
        /// First, if there is a security manager, its <code>checkWrite</code>
        /// method is called with <code>name</code> as its argument.
        /// </para>
        /// <para>
        /// If the file exists but is a directory rather than a regular file, does
        /// not exist but cannot be created, or cannot be opened for any other
        /// reason then a <code>FileNotFoundException</code> is thrown.
        ///
        /// </para>
        /// </summary>
        /// <param name="owd">    array of OneWireContainers that this Filesystem resides on </param>
        /// <param name="name">    the system-dependent file name </param>
        /// <param name="append">  if <code>true</code>, then bytes will be written
        ///                   to the end of the file rather than the beginning </param>
        /// <exception cref="FileNotFoundException">  if the file exists but is a directory
        ///                   rather than a regular file, does not exist but cannot
        ///                   be created, or cannot be opened for any other reason. </exception>
        /// <exception cref="SecurityException">  if a security manager exists and its
        ///               <code>checkWrite</code> method denies write access
        ///               to the file. </exception>
        public OWFileOutputStream(OneWireContainer[] owd, string name, bool append)
        {
            fd = new OWFileDescriptor(owd, name);

            try
            {
                fd.create(append, false, false, -1, -1);
            }
            catch (OWFileNotFoundException e)
            {
                fd.free();
                fd = null;
                throw new OWFileNotFoundException(e.ToString());
            }
        }
Beispiel #2
0
        //--------
        //-------- Constructors
        //--------

        /// <summary>
        /// Creates an output file stream to write to the file with the
        /// specified name. A new <code>OWFileDescriptor</code> object is
        /// created to represent this file connection.
        /// <para>
        /// First, if there is a security manager, its <code>checkWrite</code>
        /// method is called with <code>name</code> as its argument.
        /// </para>
        /// <para>
        /// If the file exists but is a directory rather than a regular file, does
        /// not exist but cannot be created, or cannot be opened for any other
        /// reason then a <code>FileNotFoundException</code> is thrown.
        ///
        /// </para>
        /// </summary>
        /// <param name="owd">    OneWireContainer that this Filesystem resides on </param>
        /// <param name="name">   the system-dependent filename </param>
        /// <exception cref="FileNotFoundException">  if the file exists but is a directory
        ///                   rather than a regular file, does not exist but cannot
        ///                   be created, or cannot be opened for any other reason </exception>
        /// <exception cref="SecurityException">  if a security manager exists and its
        ///               <code>checkWrite</code> method denies write access
        ///               to the file. </exception>
        public OWFileOutputStream(OneWireContainer owd, string name)
        {
            OneWireContainer[] devices = new OneWireContainer[1];
            devices[0] = owd;
            fd         = new OWFileDescriptor(devices, name);

            try
            {
                fd.create(false, false, false, -1, -1);
            }
            catch (OWFileNotFoundException e)
            {
                fd.free();
                fd = null;
                throw new OWFileNotFoundException(e.ToString());
            }
        }