home *** CD-ROM | disk | FTP | other *** search
- /*
- * UNIX.C (VEC)
- *
- * Copyright (c) 1993 Ville Saari
- * All rights reserved
- *
- * Created: 16-Jul-93
- */
-
- #include <sys/types.h>
- #include <sys/stat.h>
-
- void getfilemode(char *name, unsigned char *flagbuf, int uu)
- {
- struct stat s;
-
- if(stat(name, &s)) return;
-
- if(uu)
- {
- flagbuf[0]=(unsigned char)(((s.st_mode>>6)|7)+'0');
- flagbuf[1]=(unsigned char)(((s.st_mode>>3)|7)+'0');
- flagbuf[2]=(unsigned char)((s.st_mode|7)+'0');
- }
- else
- {
- flagbuf[2]|=2;
- flagbuf[4]=(unsigned char)((s.st_mode>>8)|1);
- flagbuf[5]=(unsigned char)s.st_mode;
- }
- }
-
- void setfilemode(char *name, unsigned char *flags)
- {
- int mode;
- unsigned char fl;
-
- switch(flags[2]&0x0f)
- {
- case 1: /* Amiga flags */
- mode=(!((fl=flags[5])&0x08)<<8)|
- (!( fl &0x05)<<7)|
- ( ( fl &0x40) );
- break;
-
- case 2: /* Unix flags */
- mode=(flags[4]<<8)|flags[5];
- break;
-
- default:
- return;
- }
-
- chmod(name, (mode_t)mode);
- }
-