File: unixstuff.c

package info (click to toggle)
python2.1 2.1.3dfsg-1sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 38,028 kB
  • ctags: 64,228
  • sloc: python: 186,023; ansic: 184,754; xml: 43,435; sh: 12,381; makefile: 3,523; perl: 3,108; lisp: 2,460; cpp: 106; sed: 2
file content (62 lines) | stat: -rw-r--r-- 1,160 bytes parent folder | download | duplicates (2)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* Fudge unix isatty and fileno for RISCOS */

#include "h.unixstuff"
#include <math.h>
#include "h.osfile"

int fileno(FILE *f)
{ return (int)f;
}

int isatty(int fn)
{ return (fn==fileno(stdin));
}

bits unixtime(bits ld,bits ex)
{ ld&=0xFF;
  ld-=51;
  if(ex<1855548004U) ld--;
  ex-=1855548004U;
  return ex/100+42949672*ld+(95*ld)/100;
}

int unlink(char *fname)
{ remove(fname);
  return 0;
}


/*#define RET(k) {printf(" %d\n",k);return k;}*/
#define RET(k) return k

int isdir(char *fn)
{ int ob;
/*  printf("isdir %s",fn);*/
  if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) RET(0);
  switch (ob)
  {   case osfile_IS_DIR:RET(1);
    case osfile_IS_IMAGE:RET(1);
  }
  RET(0);
}

int isfile(char *fn)
{ int ob;  /*printf("isfile %s",fn);*/
  if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) RET(0);
  switch (ob)
  {  case osfile_IS_FILE:RET(1);
    case osfile_IS_IMAGE:RET(1);
  }
  RET(0);
}

int exists(char *fn)
{ int ob;  /*printf("exists %s",fn);*/
  if(xosfile_read_stamped_no_path(fn,&ob,0,0,0,0,0)) RET(0);
  switch (ob)
  {  case osfile_IS_FILE:RET(1);
      case osfile_IS_DIR:RET(1);
    case osfile_IS_IMAGE:RET(1);
  }
  RET(0);
}