X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Ffile-name.c;h=fa0eb794010f75b9b2666334c08b827422ed04bd;hb=0ae31d227347f40afc6d6c35cf8b02227781b2b4;hp=1b31048e211b75dd301fc87d5c928cfe0bc764f6;hpb=6d53d2b45f5385271dd21e8df1b5ac23d20be9fb;p=pspp diff --git a/src/data/file-name.c b/src/data/file-name.c index 1b31048e21..fa0eb79401 100644 --- a/src/data/file-name.c +++ b/src/data/file-name.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ #include "libpspp/version.h" #include "gl/dirname.h" +#include "gl/dosname.h" #include "gl/intprops.h" #include "gl/minmax.h" #include "gl/relocatable.h" @@ -127,12 +128,16 @@ fn_is_special (const char *file_name) return false; } -/* Returns true if file with name NAME exists. */ +/* Returns true if file with name NAME exists, and that file is not a + directory */ bool fn_exists (const char *name) { struct stat temp; - return stat (name, &temp) == 0; + if ( stat (name, &temp) != 0 ) + return false; + + return ! S_ISDIR (temp.st_mode); } /* Environment variables. */ @@ -165,7 +170,7 @@ fn_getenv_default (const char *key, const char *def) static FILE * safety_violation (const char *fn) { - msg (SE, _("Not opening pipe file `%s' because SAFER option set."), fn); + msg (SE, _("Not opening pipe file `%s' because %s option set."), fn, "SAFER"); errno = EPERM; return NULL; } @@ -221,14 +226,7 @@ fn_open (const char *fn, const char *mode) } else #endif - { - FILE *f = fopen (fn, mode); - - if (f && mode[0] != 'r') - setvbuf (f, NULL, _IOLBF, 0); - - return f; - } + return fopen (fn, mode); } /* Counterpart to fn_open that closes file F with name FN; returns 0