Back to index

tetex-bin  3.0
Defines | Functions
readable.c File Reference
#include <kpathsea/config.h>
#include <kpathsea/c-stat.h>
#include <kpathsea/pathsearch.h>
#include <kpathsea/readable.h>
#include <kpathsea/tex-hush.h>
#include <kpathsea/truncate.h>

Go to the source code of this file.

Defines

#define READABLE(fn, st)   (access (fn, R_OK) == 0 && stat (fn, &(st)) == 0 && !S_ISDIR (st.st_mode))

Functions

string kpse_readable_file P1C (const_string, name)

Define Documentation

#define READABLE (   fn,
  st 
)    (access (fn, R_OK) == 0 && stat (fn, &(st)) == 0 && !S_ISDIR (st.st_mode))

Definition at line 62 of file readable.c.


Function Documentation

string kpse_readable_file P1C ( const_string  ,
name   
)

Definition at line 73 of file readable.c.

{
  string ret;

#ifdef WIN32
  unsigned int st = 0;
#else /* ! WIN32 */
  struct stat st;
#endif

  kpse_normalize_path((string)name);
  if (READABLE (name, st)) {
      ret = (string) name;
#ifdef ENAMETOOLONG
  } else if (errno == ENAMETOOLONG) {
      ret = kpse_truncate_filename (name);

      /* Perhaps some other error will occur with the truncated name, so
         let's call access again.  */
      if (!READABLE (ret, st)) { /* Failed.  */
          if (ret != name) free (ret);
          ret = NULL;
      }
#endif /* ENAMETOOLONG */
  } else { /* Some other error.  */
      if (errno == EACCES) { /* Maybe warn them if permissions are bad.  */
          if (!kpse_tex_hush ("readable")) {
              perror (name);
          }
      }
      ret = NULL;
  }
  return ret;
}

Here is the call graph for this function: