xref: /openbsd-src/gnu/usr.bin/cvs/vms/stat.c (revision 2286d8ed900f26153a3cd5227a124b1c0adce72f)
150bf276cStholo #include <string.h>
250bf276cStholo #include <stat.h>
350bf276cStholo #include <unixlib.h>
450bf276cStholo 
wrapped_stat(path,buffer)550bf276cStholo int wrapped_stat (path, buffer)
650bf276cStholo const char *path;
750bf276cStholo struct stat *buffer;
850bf276cStholo {
950bf276cStholo   char statpath[1024];
1050bf276cStholo   int rs;
1150bf276cStholo 
1250bf276cStholo   strcpy(statpath, path);
13461cc63eStholo   strip_trailing_slashes (statpath);
1450bf276cStholo   if(strcmp(statpath, ".") == 0)
15*2286d8edStholo   {
16*2286d8edStholo       char *wd;
17*2286d8edStholo       wd = xgetwd ();
18*2286d8edStholo       rs = stat (wd, buffer);
19*2286d8edStholo       free (wd);
20*2286d8edStholo   }
21*2286d8edStholo   else
22*2286d8edStholo       rs = stat (statpath, buffer);
2350bf276cStholo 
24*2286d8edStholo   if (rs < 0)
2550bf276cStholo       {
2650bf276cStholo       /* If stat() fails try again after appending ".dir" to the filename
2750bf276cStholo          this allows you to stat things like "bloogle/CVS" from VMS 6.1 */
2850bf276cStholo       strcat(statpath, ".dir");
2950bf276cStholo       rs = stat (statpath, buffer);
3050bf276cStholo       }
3150bf276cStholo 
3250bf276cStholo   return rs;
3350bf276cStholo }
34