File: stat.c

package info (click to toggle)
gcvs 1.0final-12
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 12,248 kB
  • ctags: 10,631
  • sloc: ansic: 71,709; cpp: 39,780; sh: 18,434; makefile: 1,915; yacc: 1,299; tcl: 1,283; perl: 910; lex: 249; csh: 185; lisp: 7
file content (33 lines) | stat: -rwxr-xr-x 663 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <string.h>
#include <stat.h>
#include <unixlib.h>

int wrapped_stat (path, buffer)
const char *path;
struct stat *buffer;
{
  char statpath[1024];
  int rs;

  strcpy(statpath, path);
  strip_trailing_slashes (statpath);
  if(strcmp(statpath, ".") == 0)
  {
      char *wd;
      wd = xgetwd ();
      rs = stat (wd, buffer);
      free (wd);
  }
  else
      rs = stat (statpath, buffer);

  if (rs < 0)
      {
      /* If stat() fails try again after appending ".dir" to the filename
         this allows you to stat things like "bloogle/CVS" from VMS 6.1 */
      strcat(statpath, ".dir");
      rs = stat (statpath, buffer);
      }

  return rs;
}