* *
* Auxiliary C functions for Interfaces.C.Streams *
* *
- * Copyright (C) 1992-2003 Free Software Foundation, Inc. *
+ * Copyright (C) 1992-2009, Free Software Foundation, Inc. *
* *
* GNAT is free software; you can redistribute it and/or modify it under *
* terms of the GNU General Public License as published by the Free Soft- *
- * ware Foundation; either version 2, or (at your option) any later ver- *
+ * ware Foundation; either version 3, or (at your option) any later ver- *
* sion. GNAT is distributed in the hope that it will be useful, but WITH- *
* OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
- * for more details. You should have received a copy of the GNU General *
- * Public License distributed with GNAT; see file COPYING. If not, write *
- * to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, *
- * MA 02111-1307, USA. *
+ * or FITNESS FOR A PARTICULAR PURPOSE. *
* *
- * As a special exception, if you link this file with other files to *
- * produce an executable, this file does not by itself cause the resulting *
- * executable to be covered by the GNU General Public License. This except- *
- * ion does not however invalidate any other reasons why the executable *
- * file might be covered by the GNU Public License. *
+ * As a special exception under Section 7 of GPL version 3, you are granted *
+ * additional permissions described in the GCC Runtime Library Exception, *
+ * version 3.1, as published by the Free Software Foundation. *
+ * *
+ * You should have received a copy of the GNU General Public License and *
+ * a copy of the GCC Runtime Library Exception along with this program; *
+ * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see *
+ * <http://www.gnu.org/licenses/>. *
* *
* GNAT was originally developed by the GNAT team at New York University. *
* Extensive contributions were provided by Ada Core Technologies Inc. *
#endif
int
-__gnat_feof (stream)
- FILE *stream;
+__gnat_feof (FILE *stream)
{
return (feof (stream));
}
int
-__gnat_ferror (stream)
- FILE *stream;
+__gnat_ferror (FILE *stream)
{
return (ferror (stream));
}
int
-__gnat_fileno (stream)
- FILE *stream;
+__gnat_fileno (FILE *stream)
{
return (fileno (stream));
}
int
-__gnat_is_regular_file_fd (fd)
- int fd;
+__gnat_is_regular_file_fd (int fd)
{
int ret;
- struct stat statbuf;
+ GNAT_STRUCT_STAT statbuf;
#ifdef __EMX__
/* Programs using screen I/O may need to reset the FPU after
__gnat_init_float();
#endif
- ret = fstat (fd, &statbuf);
+ ret = GNAT_FSTAT (fd, &statbuf);
return (!ret && S_ISREG (statbuf.st_mode));
}
char *
__gnat_full_name (char *nam, char *buffer)
{
-#if defined(__EMX__) || defined (__MINGW32__)
+#ifdef RTSS
+ /* RTSS applications have no current-directory notion, so RTSS file I/O
+ requests must use fully qualified path names, such as:
+ c:\temp\MyFile.txt (for a file system object)
+ \\.\MyDevice0 (for a device object)
+ */
+ if (nam[1] == ':' || nam[0] == '\\')
+ strcpy (buffer, nam);
+ else
+ buffer[0] = '\0';
+
+#elif defined(__EMX__) || defined (__MINGW32__)
/* If this is a device file return it as is; under Windows NT and
OS/2 a device file end with ":". */
if (nam[strlen (nam) - 1] == ':')
#elif defined (MSDOS)
_fixpath (nam, buffer);
-#elif defined (sgi)
+#elif defined (sgi) || defined (__FreeBSD__)
- /* Use realpath function which resolves links and references to .. and ..
+ /* Use realpath function which resolves links and references to . and ..
on those Unix systems that support it. Note that GNU/Linux provides it but
cannot handle more than 5 symbolic links in a full name, so we use the
getcwd approach instead. */
strncpy (buffer, __gnat_to_host_file_spec (buffer), __gnat_max_path_len);
}
+#elif defined (__vxworks)
+
+ /* On VxWorks systems, an absolute path can be represented (depending on
+ the host platform) as either /dir/file, or device:/dir/file, or
+ device:drive_letter:/dir/file. Use the __gnat_is_absolute_path
+ to verify it. */
+
+ int length;
+
+ if (__gnat_is_absolute_path (nam, strlen (nam)))
+ strcpy (buffer, nam);
+
+ else
+ {
+ length = __gnat_max_path_len;
+ __gnat_get_current_dir (buffer, &length);
+ strncat (buffer, nam, __gnat_max_path_len - length - 1);
+ }
+
#else
if (nam[0] != '/')
{
return 0;
}
+
/* If the name returned is an absolute path, it is safe to append '/'
to the path and concatenate the name of the file. */
if (buffer[0] == '/')