home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 2 BBS
/
02-BBS.zip
/
XGRP_000.SZH
/
MUNLINK.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-21
|
2KB
|
95 lines
#define INCL_DOS
#include <stddef.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <io.h>
#include <process.h>
#include <errno.h>
#ifdef TSC
#define _cdecl cdecl
#include <os2kernl.h>
#else
#include <os2.h>
#endif
#include "nofast.h"
extern void _cdecl logf (char *szFormat, ...);
extern void _fastcall my_free(void *ptr);
int _fastcall my_unlink (char *fname) {
int counter = 0;
while(unlink(fname) && (counter++ < 121)) {
if(errno == ENOENT) return 0;
if(errno == EACCES) {
if(counter == 2)
printf("\nTrouble unlinking %s...retry #",fname);
if(counter > 1) {
printf("%-5u\b\b\b\b\b",counter);
DosSleep(1000L);
}
}
else {
logf("Couldn't unlink %s -- errno = %u",fname,errno);
return -1;
}
}
if(counter) printf("\n");
if(counter > 120) {
logf("Couldn't unlink \"%s\"; please exterminate",fname);
return -1;
}
return 0;
}
int _fastcall my_rename (char *oname,char *nname) {
int counter = 0;
while(rename(oname,nname) && (counter++ < 121)) {
if(errno == ENOENT) return -1;
if(errno == EACCES) {
if(counter == 2)
printf("\nTrouble renaming %s to %s...retry #",oname,nname);
if(counter > 1) {
printf("%-5u\b\b\b\b\b",counter);
DosSleep(1000L);
}
}
else {
logf("Couldn't rename %s to %s -- errno = %u",oname,nname,errno);
return -1;
}
}
if(counter) printf("\n");
if(counter > 120) {
logf("Couldn't rename \"%s\" to \"%s\"",oname,nname);
return -1;
}
return 0;
}
void _fastcall my_free (void *ptr) {
if(ptr != NULL) free(ptr);
}