gopher/setftype.c

39 lines
905 B
C
Raw Normal View History

2012-04-16 01:48:48 +00:00
#pragma optimize 79
#include <GSOS.h>
#include <stdlib.h>
#include <gno/gno.h>
2013-08-11 04:42:57 +00:00
#include "prototypes.h"
2013-08-11 00:25:15 +00:00
int setfileattr(const char *filename, FileInfoRecGS *info, unsigned flags)
2012-04-16 01:48:48 +00:00
{
2013-08-11 00:25:15 +00:00
Word rv;
FileInfoRecGS tmp;
if (!info) return 0;
if (!flags) return 1;
tmp.pCount = 7;
tmp.pathname = (GSString255Ptr)__C2GSMALLOC(filename);
if (!tmp.pathname) return 0;
GetFileInfoGS(&tmp);
2012-04-16 01:48:48 +00:00
rv = _toolErr;
2013-08-11 00:25:15 +00:00
if (!_toolErr)
{
if (flags & ATTR_ACCESS) tmp.access = info->access;
if (flags & ATTR_FILETYPE) tmp.fileType = info->fileType;
if (flags & ATTR_AUXTYPE) tmp.auxType = info->auxType;
if (flags & ATTR_CREATETIME) tmp.createDateTime = info->createDateTime;
if (flags & ATTR_MODTIME) tmp.modDateTime = info->modDateTime;
SetFileInfoGS(&tmp);
rv = _toolErr;
}
free (tmp.pathname);
2012-04-16 01:48:48 +00:00
return rv ? 0 : 1;
2013-08-11 00:25:15 +00:00
}