home *** CD-ROM | disk | FTP | other *** search
- #include <sys/types.h>
- #include <sys/syslimits.h>
- #include <fcntl.h>
- #include "crtlocal.h"
-
- int unlink(const char *path1)
- {
- long filenum;
- int i;
- OSErr err;
- FileParam pb;
- mysleep(1);
- pb.ioCompletion = 0;
- pb.ioVRefNum = crt_ioVRefNum;
- pb.ioFVersNum = 0;
- pb.ioFDirIndex = 0;
- pb.ioNamePtr = cnv_unix_name(path1);
- err = PBGetFInfoSync((ParmBlkPtr)&pb);
- if (err) return -1;
- filenum = pb.ioFlNum;
- for (i = 0; i < OPEN_MAX; i++)
- {
- if (crt_fd_tab[i].fd && !(crt_fd_tab[i].flags & O_PIPE))
- {
- FCBPBRec pb;
- char name[99];
- pb.ioRefNum = crt_fd_tab[i].fd;
- pb.ioFCBIndx = 0;
- pb.ioCompletion = 0;
- pb.ioVRefNum = crt_ioVRefNum;
- pb.ioNamePtr = (StringPtr) name;
- PBGetFCBInfoSync(&pb);
- if (pb.ioFCBFlNm == filenum) /* deleting open file */
- {
- PBCloseSync((ParmBlkPtr)&pb);
- }
- }
- }
- err = PBDeleteSync((ParmBlkPtr)&pb);
- return err?-1:0;
- }
-