From 5152448a22144751d145c4755e4509dbe0d16b76 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Wed, 25 Oct 2000 23:28:33 +0000
Subject: [PATCH] Moved getfattr from msdirent.c to wrappers.c

---
 src/sbbs3/msdirent.c | 12 ------------
 src/sbbs3/msdirent.h |  2 --
 src/sbbs3/sbbswrap.h |  1 +
 src/sbbs3/wrappers.c | 28 ++++++++++++++++++++++++++++
 4 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/src/sbbs3/msdirent.c b/src/sbbs3/msdirent.c
index 5fc7e79001..6da8f6b967 100644
--- a/src/sbbs3/msdirent.c
+++ b/src/sbbs3/msdirent.c
@@ -88,15 +88,3 @@ void rewinddir(DIR* dir)
 	dir->end=FALSE;
 	dir->handle=_findfirst(dir->filespec,&dir->finddata);
 }
-int getfattr(char* filename)
-{
-	long handle;
-	struct _finddata_t	finddata;
-
-	if((handle=_findfirst(filename,&finddata))==-1) {
-		errno=ENOENT;
-		return(-1);
-	}
-	_findclose(handle);
-	return(finddata.attrib);
-}
\ No newline at end of file
diff --git a/src/sbbs3/msdirent.h b/src/sbbs3/msdirent.h
index d9e3e18d22..7ddd462667 100644
--- a/src/sbbs3/msdirent.h
+++ b/src/sbbs3/msdirent.h
@@ -73,8 +73,6 @@ struct dirent  *	readdir  (DIR *__dir);
 int                 closedir (DIR *__dir);
 void                rewinddir(DIR *__dir);
 
-int					getfattr(char* filename);
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/sbbs3/sbbswrap.h b/src/sbbs3/sbbswrap.h
index 420f6dd7ff..448d06be6e 100644
--- a/src/sbbs3/sbbswrap.h
+++ b/src/sbbs3/sbbswrap.h
@@ -119,6 +119,7 @@ DLLEXPORT char* ultoa(ulong, char*, int radix);
 DLLEXPORT BOOL		fexist(char *filespec);
 DLLEXPORT long		flength(char *filename);
 DLLEXPORT long		fdate(char *filename);
+DLLEXPORT int		getfattr(char* filename);
 DLLEXPORT ulong		getfreediskspace(char* path);
 
 #ifdef __cplusplus
diff --git a/src/sbbs3/wrappers.c b/src/sbbs3/wrappers.c
index f7c66e3594..21de30462f 100644
--- a/src/sbbs3/wrappers.c
+++ b/src/sbbs3/wrappers.c
@@ -55,6 +55,7 @@
 
 #include <stdio.h>		/* sprintf */
 #include <stdlib.h>		/* rand */
+#include <errno.h>		/* ENOENT definitions */
 
 #include "gen_defs.h"	/* BOOL */ 
 #include "sbbswrap.h"	/* verify prototypes */
@@ -131,6 +132,33 @@ long fdate(char *filename)
 	return(st.st_mtime);
 }
 
+/****************************************************************************/
+/* Returns the attributes (mode) for specified 'filename'					*/
+/****************************************************************************/
+int getfattr(char* filename)
+{
+#ifdef _WIN32
+	long handle;
+	struct _finddata_t	finddata;
+
+	if((handle=_findfirst(filename,&finddata))==-1) {
+		errno=ENOENT;
+		return(-1);
+	}
+	_findclose(handle);
+	return(finddata.attrib);
+#else
+	STAT st;
+
+	if(stat(filename, &st)!=0) {
+		errno=ENOENT;
+		return(-1L);
+	}
+
+	return(st.st_mode);
+#endif
+}
+
 /****************************************************************************/
 /* Returns the length of the file in 'fd'									*/
 /****************************************************************************/
-- 
GitLab