Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > d1f06a5336fd6bf4a381b72b8d2b5ce1 > files > 184

gprolog-1.2.16-3mdk.ppc.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>

<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.06-7 of 2001-11-14">
<TITLE>
 File name processing
</TITLE>
</HEAD>
<BODY TEXT=black BGCOLOR=white>
<A HREF="manual048.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual023.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<A HREF="manual050.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#66dbff"><DIV ALIGN=center><TABLE>
<TR><TD><FONT SIZE=4><B><A NAME="htoc239">7.26</A></B></FONT></TD>
<TD WIDTH="100%" ALIGN=center><FONT SIZE=4><B>File name processing</B></FONT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><UL>
<LI><A HREF="manual049.html#toc192"> <TT>absolute_file_name/2</TT></A>
<LI><A HREF="manual049.html#toc193"> <TT>decompose_file_name/4</TT></A>
<LI><A HREF="manual049.html#toc194"> <TT>prolog_file_name/2</TT></A>
</UL>
<BR>
<A NAME="toc192"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc240">7.26.1</A></B></TD>
<TD WIDTH="100%" ALIGN=center><TT><B>absolute_file_name/2</B></TT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
<A NAME="absolute-file-name/2"></A>
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
absolute_file_name(+atom, atom)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>absolute_file_name(File1, File2)</TT> succeeds if <TT>File2</TT> is
the absolute pathname associated to the relative file name <TT>File1</TT>.
<TT>File1</TT> can contain <TT>$<I>VAR_NAME</I></TT> sub-strings. When
such a sub-string is encountered, it is expanded with the value of the
environment variable whose name is <I><TT>VAR_NAME</TT></I> if exists
(otherwise no expansion is done). <TT>File1</TT> can also begin with a
sub-string <TT>~<I>USER_NAME</I>/</TT>, this is expanded as the home
directory of the user <I><TT>USER_NAME</TT></I>. If
<I><TT>USER_NAME</TT></I> does not exist <TT>File1</TT> is an invalid
pathname. If no <I><TT>USER_NAME</TT></I> is given (i.e. <TT>File1</TT>
begins with <TT>~/</TT>) the <TT>~</TT> character is expanded as the
value of the environment variable <TT>HOME</TT>. If the <TT>HOME</TT>
variable is not defined <TT>File1</TT> is an invalid pathname. Relative
references to the current directory (<TT>/./</TT> sub-string) and to the
parent directory (<TT>/../</TT> sub-strings) are removed and no longer
appear in <TT>File2</TT>. <TT>File1</TT> is also invalid if it contains too
many <TT>/../</TT> consecutive sub-strings (i.e. parent directory relative
references). Finally if <TT>File1</TT> is <TT>user</TT> then <TT>File2</TT>
is also unified with <TT>user</TT> to allow this predicate to be called on
Prolog file names (since <TT>user</TT> in DEC-10 input/output predicates
denotes the current input/output stream). <BR>
<BR>
Most predicates using a file name implicitly call this predicate to obtain
the desired file, e.g. <TT>open/4</TT>. <BR>
<BR>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>File1</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>File1</TT> is neither a variable nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, File1)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>File2</TT> is neither a variable nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, File2)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>File1</TT> is an atom but not a valid pathname</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(os_path, File1)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
GNU Prolog predicate.<BR>
<BR>
<A NAME="toc193"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc241">7.26.2</A></B></TD>
<TD WIDTH="100%" ALIGN=center><TT><B>decompose_file_name/4</B></TT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
decompose_file_name(+atom, ?atom, ?atom, ?atom)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>decompose_file_name(File, Directory, Prefix, Suffix)</TT> decomposes
the pathname <TT>File</TT> and extracts the <TT>Directory</TT> part
(characters before the last <TT>/</TT>), the <TT>Prefix</TT> part
(characters after the last <TT>/</TT> and before the last <TT>.</TT> or
until the end if there is no suffix) and the <TT>Suffix</TT> part
(characters from the last <TT>.</TT> to the end of the string). <BR>
<BR>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>File</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>File</TT> is neither a variable nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, File)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Directory</TT> is neither a variable nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, Directory)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Prefix</TT> is neither a variable nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, Prefix)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Suffix</TT> is neither a variable nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, Suffix)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
GNU Prolog predicate.<BR>
<BR>
<A NAME="toc194"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc242">7.26.3</A></B></TD>
<TD WIDTH="100%" ALIGN=center><TT><B>prolog_file_name/2</B></TT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
<A NAME="prolog-file-name/2"></A>
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
prolog_file_name(+atom, ?atom)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>prolog_file_name(File1, File2)</TT> unifies <TT>File2</TT> with the
Prolog file name associated to <TT>File1</TT>. More precisely <TT>File2</TT>
is computed as follows:
<UL><LI>if <TT>File1</TT> has a suffix or if it is <TT>user</TT> then
<TT>File2</TT> is unified with <TT>File1</TT>.<BR>
<BR>
<LI>else if the file whose name is <TT>File1</TT> + <TT>'.pl'</TT> exists
then <TT>File2</TT> is unified with this name.<BR>
<BR>
<LI>else if the file whose name is <TT>File1</TT> + <TT>'.pro'</TT> exists
then <TT>File2</TT> is unified with this name.<BR>
<BR>
<LI>else <TT>File2</TT> is unified with the name <TT>File1</TT> +
<TT>'.pl'</TT>.</UL>
This predicate uses <TT>absolute_file_name/2</TT> to check the existence
of a file (section&nbsp;<A HREF="#absolute-file-name/2">7.26.1</A>).<BR>
<BR>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>File1</TT> is a variable</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>instantiation_error</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>File1</TT> is neither a variable nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, File1)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>File2</TT> is neither a variable nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, File2)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>File1</TT> is an atom but not a valid pathname</TD>
<TD VALIGN=top ALIGN=center NOWRAP>&nbsp;&nbsp;</TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(os_path, File1)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
GNU Prolog predicate.<BR>
<BR>

<HR SIZE=2>
Copyright (C) 1999-2002 Daniel Diaz
<BR>
<BR>
Verbatim copying and distribution of this entire article is permitted in any
medium, provided this notice is preserved. <BR>
<BR>
<A HREF="index.html#copyright">More about the copyright</A>
<HR>
<A HREF="manual048.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual023.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<A HREF="manual050.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>