aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/io/unix.c
diff options
context:
space:
mode:
authorJerry DeLisle <jvdelisle@gcc.gnu.org>2010-03-20 14:39:00 +0000
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2010-03-20 14:39:00 +0000
commit41c3cddc6b5d279f56f02709a92f55d61e4675c7 (patch)
tree1f0dd89e327efd48666fe5142e7c12087383968d /libgfortran/io/unix.c
parentd491d2af314a455227666dd245dc27ea0dfdea8e (diff)
downloadgcc-41c3cddc6b5d279f56f02709a92f55d61e4675c7.zip
gcc-41c3cddc6b5d279f56f02709a92f55d61e4675c7.tar.gz
gcc-41c3cddc6b5d279f56f02709a92f55d61e4675c7.tar.bz2
re PR fortran/43409 (I/O: INQUIRE for SIZE does not work.)
2010-03-20 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/43409 * ioparm.def: Change inquire size variable to type pointer to GFC_IO_INT type. 2010-03-20 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/43409 * io/unix.h: Add prototype for new function to return file size. * io/unix.c (file_size): New function. * io/inquire.c (inquire_via_unit): Use new function. (inquire_via_filename): Use new function. From-SVN: r157593
Diffstat (limited to 'libgfortran/io/unix.c')
-rw-r--r--libgfortran/io/unix.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index bd2b659..4435674 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -1475,6 +1475,22 @@ file_exists (const char *file, gfc_charlen_type file_len)
}
+/* file_size()-- Returns the size of the file. */
+
+GFC_IO_INT
+file_size (const char *file, gfc_charlen_type file_len)
+{
+ char path[PATH_MAX + 1];
+ gfstat_t statbuf;
+
+ if (unpack_filename (path, file, file_len))
+ return -1;
+
+ if (stat (path, &statbuf) < 0)
+ return -1;
+
+ return (GFC_IO_INT) statbuf.st_size;
+}
static const char yes[] = "YES", no[] = "NO", unknown[] = "UNKNOWN";