From 1400f577d255cef06ab149b11117a7808dbbd71d Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Fri, 6 Jun 2003 21:59:33 +0000 Subject: [PATCH] Created ftouch() function. Updated nopen() and fnopen() prototypes to take const char* for filename. --- src/sbbs3/nopen.c | 16 ++++++++++++++-- src/sbbs3/sbbs.h | 5 +++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/sbbs3/nopen.c b/src/sbbs3/nopen.c index 6977e68e89..3d758ca502 100644 --- a/src/sbbs3/nopen.c +++ b/src/sbbs3/nopen.c @@ -43,7 +43,7 @@ /* number of times if the attempted file is already open or denying access */ /* for some other reason. All files are opened in BINARY mode. */ /****************************************************************************/ -int nopen(char *str, int access) +int nopen(const char* str, int access) { int file,share,count=0; @@ -64,7 +64,7 @@ int nopen(char *str, int access) /* This function performs an nopen, but returns a file stream with a buffer */ /* allocated. */ /****************************************************************************/ -FILE* fnopen(int *fd, char *str, int access) +FILE* fnopen(int* fd, const char* str, int access) { char mode[128]; int file; @@ -100,3 +100,15 @@ FILE* fnopen(int *fd, char *str, int access) setvbuf(stream,NULL,_IOFBF,FNOPEN_BUF_SIZE); return(stream); } + +BOOL ftouch(const char* fname) +{ + int file; + + file=nopen(fname,O_WRONLY|O_CREAT); + if(file<0) + return(FALSE); + close(file); + + return(TRUE); +} diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h index b70a85375a..94aaf8ae70 100644 --- a/src/sbbs3/sbbs.h +++ b/src/sbbs3/sbbs.h @@ -937,8 +937,9 @@ int pstrcmp(char **str1, char **str2); /* Compares pointers to pointers */ int strsame(char *str1, char *str2); /* Compares number of same chars */ /* nopen.c */ -int nopen(char *str, int access); -FILE * fnopen(int *file, char *str, int access); +int nopen(const char* str, int access); +FILE * fnopen(int* file, const char* str, int access); +BOOL ftouch(const char* fname); /* load_cfg.c */ BOOL md(char *path); -- GitLab