<ppdoc>
<copyright>
Copyright (c) 2001 by Addison Wesley Longman, Inc. This material may
be distributed only subject to the terms and conditions set forth in
the Open Publication License, v1.0 or later (the latest version is
presently available at http://www.opencontent.org/openpub/).
<p/>
Distribution of substantively modified versions of this document is
prohibited without the explicit permission of the copyright holder.
<p/>
Distribution of the work or derivative of the work in any standard
(paper) book form is prohibited unless prior permission is obtained
from the copyright holder.
</copyright>
<class name="FileTest" type="module" ref="xref-000001">
<p/>
  <modulename>FileTest</modulename> implements file test operations similar to those used
  in <classname>File::Stat</classname>.
<p/>
  <methods type="instance">
        <method name="blockdev?" ref="blockdev_qm">
      <callseq>
        FileTest.blockdev?( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if the named file is a block device, <const>false</const>
      if it isn't or 
      if the operating system doesn't support this feature.
<p/>
<codefragment>
<fullcode><![CDATA[        FileTest.blockdev?( "testfile" )
]]></fullcode><rubycode>
<tr>
  <td><tt>FileTest.blockdev?(<nbsp/>"testfile"<nbsp/>)</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="chardev?" ref="chardev_qm">
      <callseq>
        FileTest.chardev?( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if the named file is a character device, <const>false</const>
      if it isn't or 
      if the operating system doesn't support this feature.
<p/>
<codefragment>
<fullcode><![CDATA[        FileTest.chardev?( "/dev/tty" )
]]></fullcode><rubycode>
<tr>
  <td><tt>FileTest.chardev?(<nbsp/>"/dev/tty"<nbsp/>)</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="directory?" ref="directory_qm">
      <callseq>
        FileTest.directory?( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if this named file is a directory, <const>false</const> 
      otherwise.
<p/>
<codefragment>
<fullcode><![CDATA[        FileTest.directory?( "." )
]]></fullcode><rubycode>
<tr>
  <td><tt>FileTest.directory?(<nbsp/>"."<nbsp/>)</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="executable?" ref="executable_qm">
      <callseq>
        FileTest.executable?( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if the named file is executable.
      The tests are made using the effective
      owner of the process.
<p/>
<codefragment>
<fullcode><![CDATA[        FileTest.executable?( "testfile" )
]]></fullcode><rubycode>
<tr>
  <td><tt>FileTest.executable?(<nbsp/>"testfile"<nbsp/>)</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="executable_real?" ref="executable_real_qm">
      <callseq>
        FileTest.executable_real?( <obj>aString</obj> )
    <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Same as <mim><file>filetest</file><front>FileTest</front><back>executable?</back><mref>executable_qm</mref></mim>, but tests using the real owner of the
      process.
<p/>
      </desc>
    </method>
<p/>
        <method name="exist?" ref="exist_qm">
      <callseq>
        FileTest.exist? ( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if the named file exists.
<p/>
<codefragment>
<fullcode><![CDATA[        FileTest.exist?( "testfile" )
]]></fullcode><rubycode>
<tr>
  <td><tt>FileTest.exist?(<nbsp/>"testfile"<nbsp/>)</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="exists?" ref="exists_qm">
      <callseq>
        FileTest.exists? ( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Synonym for <mmm><file>filetest</file><front>FileTest</front><back>exist?</back><mref>exist_qm</mref></mmm>.
<p/>
      </desc>
    </method>
<p/>
        <method name="file?" ref="file_qm">
      <callseq>
        FileTest.file?( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
     Returns <const>true</const> if the named file is a regular file (not a device 
     file, pipe, socket, etc.).
<p/>
<codefragment>
<fullcode><![CDATA[        FileTest.file?( "testfile" )
]]></fullcode><rubycode>
<tr>
  <td><tt>FileTest.file?(<nbsp/>"testfile"<nbsp/>)</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="grpowned?" ref="grpowned_qm">
      <callseq>
        FileTest.grpowned?( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if the effective group id of the process is the same 
      as the group id of the named file.
      On Windows NT, returns <const>false</const>.
<p/>
<codefragment>
<fullcode><![CDATA[        FileTest.grpowned?( "/etc/passwd" )
]]></fullcode><rubycode>
<tr>
  <td><tt>FileTest.grpowned?(<nbsp/>"/etc/passwd"<nbsp/>)</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="owned?" ref="owned_qm">
      <callseq>
        FileTest.owned?( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if the effective user id of the process is the same 
      as the owner of the named file.
<p/>
<codefragment>
<fullcode><![CDATA[        FileTest.owned?( "/etc/passwd" )
]]></fullcode><rubycode>
<tr>
  <td><tt>FileTest.owned?(<nbsp/>"/etc/passwd"<nbsp/>)</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="pipe?" ref="pipe_qm">
      <callseq>
        FileTest.pipe?( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if the operating system supports pipes and
      the named file is a pipe, <const>false</const> otherwise.
<p/>
<codefragment>
<fullcode><![CDATA[        FileTest.pipe?( "testfile" )
]]></fullcode><rubycode>
<tr>
  <td><tt>FileTest.pipe?(<nbsp/>"testfile"<nbsp/>)</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="readable?" ref="readable_qm">
      <callseq>
        FileTest.readable?( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if the named file is readable by the effective
      user id of this process.
<p/>
<codefragment>
<fullcode><![CDATA[        FileTest.readable?( "testfile" )
]]></fullcode><rubycode>
<tr>
  <td><tt>FileTest.readable?(<nbsp/>"testfile"<nbsp/>)</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="readable_real?" ref="readable_real_qm">
      <callseq>
        FileTest.readable_real?( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if the named file is readable by the real
      user id of this process.
<p/>
<codefragment>
<fullcode><![CDATA[        FileTest.readable_real?( "testfile" )
]]></fullcode><rubycode>
<tr>
  <td><tt>FileTest.readable_real?(<nbsp/>"testfile"<nbsp/>)</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="setgid?" ref="setgid_qm">
      <callseq>
        FileTest.setgid?( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if the named file's set-group-id
      permission bit is set, and <const>false</const> if it isn't or
      if the operating system doesn't support this feature.
<p/>
<codefragment>
<fullcode><![CDATA[        FileTest.setgid?( "/usr/sbin/lpc" )
]]></fullcode><rubycode>
<tr>
  <td><tt>FileTest.setgid?(<nbsp/>"/usr/sbin/lpc"<nbsp/>)</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="setuid?" ref="setuid_qm">
      <callseq>
        FileTest.setuid?( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if the named  file's set-user-id
      permission bit is set, and <const>false</const> if it isn't or
      if the operating system doesn't support this feature.
<p/>
<codefragment>
<fullcode><![CDATA[        FileTest.setuid?( "/bin/su" )
]]></fullcode><rubycode>
<tr>
  <td><tt>FileTest.setuid?(<nbsp/>"/bin/su"<nbsp/>)</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="size" ref="size">
      <callseq>
        FileTest.size( <obj>aString</obj> )
        <returns><obj>anInteger</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the size of the named file in bytes.
<p/>
<codefragment>
<fullcode><![CDATA[        FileTest.size( "testfile" )
]]></fullcode><rubycode>
<tr>
  <td><tt>FileTest.size(<nbsp/>"testfile"<nbsp/>)</tt></td>
  <td>&#187;</td>
  <td><tt>66</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="size?" ref="size_qm">
      <callseq>
        FileTest.size?( <obj>aString</obj> )
        <returns><obj>aFixnum</obj> or <tt>nil</tt></returns>
      </callseq>
      <desc>
<p/>
      Returns <tt>nil</tt> if the named file is of zero length; otherwise,
      returns a nonzero <obj>aFixnum</obj>.
<p/>
<codefragment>
<fullcode><![CDATA[        FileTest.size?( "testfile" )
        FileTest.size?( "/dev/zero" )
]]></fullcode><rubycode>
<tr>
  <td><tt>FileTest.size?(<nbsp/>"testfile"<nbsp/>)</tt></td>
  <td>&#187;</td>
  <td><tt>66</tt></td>
</tr>
<tr>
  <td><tt>FileTest.size?(<nbsp/>"/dev/zero"<nbsp/>)</tt></td>
  <td>&#187;</td>
  <td><tt>nil</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="socket?" ref="socket_qm">
      <callseq>
        FileTest.socket?( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if the named file is a socket, <const>false</const> if
      it isn't or 
      if the operating system doesn't support this feature.
<p/>
      </desc>
    </method>
<p/>
        <method name="sticky?" ref="sticky_qm">
      <callseq>
        FileTest.sticky?( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if the named file has its sticky bit set,
      <const>false</const> if it doesn't or if the operating system doesn't
      support this feature.
<p/>
      </desc>
    </method>
<p/>
        <method name="symlink?" ref="symlink_qm">
      <callseq>
        FileTest.symlink?( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if the named file is a symbolic link,
      <const>false</const> if it isn't or if the operating system doesn't
      support this feature.
<p/>
      </desc>
    </method>
<p/>
        <method name="writable?" ref="writable_qm">
      <callseq>
        FileTest.writable?( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if the named file is writable by the effective
      user id of this process.
<p/>
      </desc>
    </method>
<p/>
        <method name="writable_real?" ref="writable_real_qm">
      <callseq>
        FileTest.writable_real?( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if the named file is writable by the real
      user id of this process.
<p/>
      </desc>
    </method>
<p/>
        <method name="zero?" ref="zero_qm">
      <callseq>
        FileTest.zero?( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if the named file is of zero length, <const>false</const>
      otherwise.
<p/>
      </desc>
    </method>
<p/>
  </methods>
<p/>
</class>
</ppdoc>
