diff --git a/cmake/sources.cmake b/cmake/sources.cmake
index a5f165d..989ca36 100644
--- a/cmake/sources.cmake
+++ b/cmake/sources.cmake
@@ -164,6 +164,7 @@ SET(sword_base_utilfns_SOURCES
 	src/utilfuns/ftpparse.c
 	src/utilfuns/url.cpp
 	src/utilfuns/roman.cpp
+        src/utilfuns/swopen.cpp
 )
 SOURCE_GROUP("src\\utilfns" FILES ${sword_base_utilfns_SOURCES})
 
diff --git a/include/swopen.h b/include/swopen.h
new file mode 100644
index 0000000..a4c81f0
--- /dev/null
+++ b/include/swopen.h
@@ -0,0 +1,40 @@
+/******************************************************************************
+*  swopen.h  - declarations for sword file handling methods
+*
+* $Id$
+*
+* Copyright 2013 CrossWire Bible Society (http://www.crosswire.org)
+*       CrossWire Bible Society
+*       P. O. Box 2528
+*       Tempe, AZ  85280-2528
+*
+* This program is free software; you can redistribute it and/or modify it
+* under the terms of the GNU General Public License as published by the
+* Free Software Foundation version 2.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+* General Public License for more details.
+*
+*/
+#ifndef SWOPEN_H
+#define SWOPEN_H
+
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int swopen(const char* filename, int flags, int mode);
+int swaccess(const char* filename, int mode);
+int swremove(const char* filename);
+int swmkdir(const char* filename, int mode);
+FILE* swfopen(const char* filename, const char *mode);
+
+#ifdef __cplusplus
+}
+#endif
+// swopendir, swrewinddir, swdirclose, swgetenv, swfopen
+#endif // SWOPEN_H
diff --git a/src/mgr/curlftpt.cpp b/src/mgr/curlftpt.cpp
index 046291e..3362918 100644
--- a/src/mgr/curlftpt.cpp
+++ b/src/mgr/curlftpt.cpp
@@ -24,6 +24,7 @@
 #include <curlftpt.h>
 
 #include <fcntl.h>
+#include <swopen.h>
 
 #include <curl/curl.h>
 #include <curl/easy.h>
@@ -57,7 +58,7 @@ int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) {
 	struct FtpFile *out=(struct FtpFile *)stream;
 	if (out && !out->stream && !out->destBuf) {
 		/* open file for writing */
-		out->stream=fopen(out->filename, "wb");
+        out->stream=swfopen(out->filename, "wb");
 		if (!out->stream)
 			return -1; /* failure, can't open file to write */
 	}
diff --git a/src/mgr/filemgr.cpp b/src/mgr/filemgr.cpp
index 5b45049..0021ea4 100644
--- a/src/mgr/filemgr.cpp
+++ b/src/mgr/filemgr.cpp
@@ -22,6 +22,7 @@
 
 #include <filemgr.h>
 #include <utilstr.h>
+#include <swopen.h>
 
 #include <dirent.h>
 #include <fcntl.h>
@@ -225,14 +226,14 @@ int FileMgr::sysOpen(FileDesc *file) {
 				file->next = files;
 				files = file;
 			}
-			if ((!access(file->path, 04)) || ((file->mode & O_CREAT) == O_CREAT)) {	// check for at least file exists / read access before we try to open
+            if ((!swaccess(file->path, 04)) || ((file->mode & O_CREAT) == O_CREAT)) {	// check for at least file exists / read access before we try to open
 				char tries = (((file->mode & O_RDWR) == O_RDWR) && (file->tryDowngrade)) ? 2 : 1;  // try read/write if possible
 				for (int i = 0; i < tries; i++) {
 					if (i > 0) {
 						file->mode = (file->mode & ~O_RDWR);	// remove write access
 						file->mode = (file->mode | O_RDONLY);// add read access
 					}
-					file->fd = ::open(file->path, file->mode|O_BINARY, file->perms);
+                    file->fd = swopen(file->path, file->mode|O_BINARY, file->perms);
 
 					if (file->fd >= 0)
 						break;
@@ -275,7 +276,7 @@ signed char FileMgr::trunc(FileDesc *file) {
 		if (i == 9999)
 			return -2;
 
-		int fd = ::open(buf, O_CREAT|O_RDWR, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
+        int fd = swopen(buf, O_CREAT|O_RDWR, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
 		if (fd < 0)
 			return -3;
 	
@@ -289,7 +290,7 @@ signed char FileMgr::trunc(FileDesc *file) {
 		if (size < 1) {
 			// zero out the file
 			::close(file->fd);
-			file->fd = ::open(file->path, O_TRUNC, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
+            file->fd = swopen(file->path, O_TRUNC, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
 			::close(file->fd);
 			file->fd = -77;	// force file open by filemgr
 			// copy tmp file back (dumb, but must preserve file permissions)
@@ -327,7 +328,7 @@ signed char FileMgr::existsFile(const char *ipath, const char *ifileName)
 		ch = path + strlen(path);
 		sprintf(ch, "/%s", ifileName);
 	}
-	signed char retVal = !access(path, 04);
+    signed char retVal = !swaccess(path, 04);
 	delete [] path;
 	return retVal;
 }
@@ -349,7 +350,7 @@ signed char FileMgr::existsDir(const char *ipath, const char *idirName)
 		ch = path + strlen(path);
 		sprintf(ch, "/%s", idirName);
 	}
-	signed char retVal = !access(path, 04);
+    signed char retVal = !swaccess(path, 04);
 	delete [] path;
 	return retVal;
 }
@@ -368,17 +369,13 @@ int FileMgr::createParent(const char *pName) {
 	}
 	buf[end] = 0;
 	if (strlen(buf)>0) {
-		if (access(buf, 02)) {  // not exists with write access?
-			if ((retCode = mkdir(buf
-#ifndef WIN32
+        if (swaccess(buf, 02)) {  // not exists with write access?
+            if ((retCode = swmkdir(buf
 					, 0755
-#endif
 					))) {
 				createParent(buf);
-				retCode = mkdir(buf
-#ifndef WIN32
+                retCode = swmkdir(buf
 					, 0755
-#endif
 					);
 			}
 		}
@@ -390,7 +387,7 @@ int FileMgr::createParent(const char *pName) {
 	
 
 int FileMgr::openFileReadOnly(const char *fName) {
-	int fd = ::open(fName, O_RDONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
+    int fd = swopen(fName, O_RDONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
 	return fd;
 }
 
@@ -398,10 +395,10 @@ int FileMgr::openFileReadOnly(const char *fName) {
 int FileMgr::createPathAndFile(const char *fName) {
 	int fd;
 	
-	fd = ::open(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
+    fd = swopen(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
 	if (fd < 1) {
 		createParent(fName);
-		fd = ::open(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
+        fd = swopen(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
 	}
 	return fd;
 }
@@ -411,7 +408,7 @@ int FileMgr::copyFile(const char *sourceFile, const char *targetFile) {
 	int sfd, dfd, len;
 	char buf[4096];
 
-	if ((sfd = ::open(sourceFile, O_RDONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH)) < 1)
+    if ((sfd = swopen(sourceFile, O_RDONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH)) < 1)
 		return -1;
 	if ((dfd = createPathAndFile(targetFile)) < 1)
 		return -1;
@@ -429,7 +426,7 @@ int FileMgr::copyFile(const char *sourceFile, const char *targetFile) {
 
 
 int FileMgr::removeFile(const char *fName) {
-	return ::remove(fName);
+    return swremove(fName);
 }
 
 char FileMgr::getLine(FileDesc *fDesc, SWBuf &line) {
diff --git a/src/mgr/installmgr.cpp b/src/mgr/installmgr.cpp
index 183989d..702ac15 100644
--- a/src/mgr/installmgr.cpp
+++ b/src/mgr/installmgr.cpp
@@ -33,6 +33,7 @@ extern "C" {
 #include <utilstr.h>
 
 #include <fcntl.h>
+#include <swopen.h>
 
 #include <swmgr.h>
 #include <swmodule.h>
diff --git a/src/utilfuns/swopen.cpp b/src/utilfuns/swopen.cpp
new file mode 100644
index 0000000..6a962b1
--- /dev/null
+++ b/src/utilfuns/swopen.cpp
@@ -0,0 +1,387 @@
+/******************************************************************************
+*  swopen.cpp  - code for swopen to wrap file opening
+*
+* $Id$
+*
+* Copyright 2013 CrossWire Bible Society (http://www.crosswire.org)
+*	CrossWire Bible Society
+*	P. O. Box 2528
+*	Tempe, AZ  85280-2528
+*
+* This program is free software; you can redistribute it and/or modify it
+* under the terms of the GNU General Public License as published by the
+* Free Software Foundation version 2.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+* General Public License for more details.
+*
+*/
+
+#include "swopen.h"
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+#ifdef WIN32
+#include <windows.h>
+#include <errno.h>
+#include <wchar.h>
+#include <direct.h>
+#include <io.h>
+#include <sys/utime.h>
+#else
+#include <unistd.h>
+#include <errno.h>
+#endif
+
+#include <swbuf.h>
+#include <utf8utf16.h>
+
+wchar_t* _str_to_utf16(const char *str) {
+    sword::UTF8UTF16 *filter = new sword::UTF8UTF16();
+    sword::SWBuf swStr = str;
+    filter->processText(swStr, NULL, NULL);
+    delete filter;
+
+    return (wchar_t*) swStr.c_str();
+}
+
+/**
+ * @brief cross-platform method for opening a file
+ *
+ * This wraps either a simple call to the clib to open a file or
+ * to the wide-character API on Windows to open a file
+ *
+ * Arguments and return are the same as the standard clib open
+ * arguments.
+ *
+ * @param filename
+ * @param flags
+ * @param mode
+ * @return
+ */
+extern "C" int
+swopen(const char   *filename,
+       int          flags,
+       int          mode) {
+#ifdef WIN32
+    HANDLE hFile;
+    DWORD  dwDesiredAccess      = 0;
+    DWORD  dwFlagsAndAttributes = 0;
+    DWORD  dwDisposition        = OPEN_EXISTING;
+    DWORD  dwSharedAccess       = FILE_SHARE_READ | FILE_SHARE_DELETE;
+    // Convert name to UTF-16 for file paths
+    wchar_t* wfilename = _str_to_utf16(filename);
+    int retval;
+    int save_errno;
+
+    if (wfilename == NULL) {
+        errno = EINVAL;
+        return -1;
+    }
+
+    // Set up the access modes and other attributes
+    if ((flags & _O_CREAT) && (mode & _S_IREAD)) {
+        if (! (mode & _S_IWRITE))
+            dwFlagsAndAttributes    = FILE_ATTRIBUTE_READONLY; // Sets file to 'read only' after the file gets closed
+    }
+    if ( !(flags & _O_ACCMODE)) {
+        // Equates to _O_RDONLY
+        if (flags & _O_TRUNC) {
+            errno = EINVAL;
+        }
+
+        dwDesiredAccess |= GENERIC_READ;
+        dwSharedAccess  |= FILE_SHARE_WRITE;
+    }
+    if (flags & _O_WRONLY) {
+        if (flags & _O_RDWR) {
+            errno = EINVAL;
+        }
+
+        dwDesiredAccess |= GENERIC_WRITE;
+    }
+    if (flags & _O_RDWR) {
+        dwDesiredAccess |= GENERIC_READ;
+        dwDesiredAccess |= GENERIC_WRITE;
+    }
+    if (flags & _O_TRUNC) {
+        if (flags & _O_CREAT)
+            dwDisposition = CREATE_ALWAYS;
+        else
+            dwDisposition = TRUNCATE_EXISTING;
+    }
+    if ((flags & _O_CREAT) && !(flags & _O_TRUNC)) {
+        if (flags & _O_EXCL)
+            dwDisposition = CREATE_NEW;
+        else
+            dwDisposition = OPEN_ALWAYS;
+    }
+    if (flags & _O_CREAT) {
+        // Handle the other flags that can be attached to _O_CREAT
+        if ((flags & _O_TEMPORARY) || (flags & _O_SHORT_LIVED))
+            dwFlagsAndAttributes |= FILE_ATTRIBUTE_TEMPORARY;
+
+        if (flags & _O_TEMPORARY)
+            dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
+    }
+    if ((flags & _O_SEQUENTIAL) || (flags & _O_APPEND)) {
+        dwFlagsAndAttributes |= FILE_FLAG_SEQUENTIAL_SCAN;
+    }
+    else if (flags & _O_RANDOM) {
+        dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
+    }
+
+    if (0 == dwFlagsAndAttributes) {
+        dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;
+    }
+    hFile = CreateFileW(wfilename, dwDesiredAccess, dwSharedAccess, NULL, dwDisposition, dwFlagsAndAttributes, NULL);
+
+    if (INVALID_HANDLE_VALUE == hFile) {
+        retval = (-1);
+
+        switch (GetLastError()) {
+#define CASE(a,b) case ERROR_##a: errno = b; break
+            CASE (FILE_NOT_FOUND, ENOENT);
+            CASE (PATH_NOT_FOUND, ENOENT);
+            CASE (ACCESS_DENIED, EACCES);
+            CASE (NOT_SAME_DEVICE, EXDEV);
+            CASE (LOCK_VIOLATION, EACCES);
+            CASE (SHARING_VIOLATION, EACCES);
+            CASE (FILE_EXISTS, EEXIST);
+            CASE (ALREADY_EXISTS, EEXIST);
+#undef CASE
+            default: errno = EIO;
+        }
+    } else {
+        retval = _open_osfhandle((long)hFile, flags);
+    }
+
+    if ((-1) != retval) {
+        // We have a valid file handle. Set binary/text mode as appropriate
+        if ((!(flags & _O_TEXT)) && (_fmode == _O_BINARY))
+            _setmode(retval, _O_BINARY);
+        else if ((flags & _O_TEXT) || (_fmode == _O_TEXT))
+            _setmode(retval, _O_TEXT);
+        else
+            _setmode(retval, _O_BINARY);
+    }
+
+    save_errno = errno;
+    errno = save_errno;
+
+    return retval;
+#else
+    int fd;
+    do
+        fd = open (filename, flags, mode);
+    while ( fd == -1 && errno == EINTR);
+    return fd;
+#endif
+}
+
+/**
+ * @brief cross-platform method for determining read, write, execute, etc permission
+ *
+ * The arguments and return values are the same as they would be to the access method
+ * in your standard clib.
+ *
+ * This wraps the wide-character API calls on Windows.
+ *
+ * @param filename
+ * @param mode
+ * @return
+ */
+extern "C" int swaccess(const char *filename, int mode) {
+#ifdef WIN32
+    wchar_t *wfilename = _str_to_utf16(filename);
+    int retval;
+
+    if (wfilename == NULL) {
+        errno = EINVAL;
+        return -1;
+    }
+
+#ifndef X_OK
+#define X_OK 1
+#endif
+
+    retval = _waccess (wfilename, mode & ~X_OK);
+
+    return retval;
+#else
+    return access (filename, mode);
+#endif
+}
+
+/**
+ * @brief cross-platform method for removing a file or directory
+ *
+ * Arguments are the same as the standard clib arguments to the
+ * access method. Will either call that method in a UTF-8 friendly
+ * environment or call the wide character APIs on Windows.
+ *
+ * @param filename
+ * @return
+ */
+int swremove (const char *filename) {
+#ifdef WIN32
+    wchar_t *wfilename = _str_to_utf16(filename);
+    int retval;
+
+    if (wfilename == NULL) {
+        errno = EINVAL;
+        return -1;
+    }
+
+    retval = _wremove (wfilename);
+    if (retval == -1)
+        retval = _wrmdir (wfilename);
+    return retval;
+#else
+    return remove (filename);
+#endif
+}
+
+/**
+ * @brief cross-platform method for creating a directory
+ *
+ * Accepts the same arguments as the clib mkdir method. On
+ * Windows this will invoke the wide character API.
+ *
+ * @param filename
+ * @param mode
+ * @return
+ */
+extern "C" int swmkdir(const char *filename, int mode) {
+#ifdef WIN32
+    wchar_t* wfilename = _str_to_utf16(filename);
+    int retval;
+
+    if (wfilename == NULL) {
+        errno = EINVAL;
+        return -1;
+    }
+
+    retval = _wmkdir (wfilename);
+
+    return retval;
+#else
+    return mkdir (filename, mode);
+#endif
+}
+
+/**
+ * @brief cross-platform method for opening a file
+ *
+ * @param filename
+ * @param mode
+ * @return
+ */
+extern "C" FILE* swfopen(const char *filename, const char* mode) {
+#ifdef WIN32
+  int   hFile;
+  int   flags  = 0;
+  char priv_mode[4];
+  FILE *retval = NULL;
+
+  if ((NULL == filename) || (NULL == mode))
+  {
+    errno = EINVAL;
+    goto out;
+  }
+  if ((strlen(mode) < 1) || (strlen(mode) > 3))
+  {
+    errno = EINVAL;
+    goto out;
+  }
+
+  strncpy(priv_mode, mode, 3);
+  priv_mode[3] = '\0';
+
+  /* Set up any flags to pass to 'swopen()' */
+  if (3 == strlen(priv_mode))
+  {
+    if (('c' == priv_mode[2]) || ('n' == priv_mode[2]))
+      priv_mode[2] = '\0';
+    else
+    {
+      if (0 == strcmp(priv_mode, "a+b"))
+        flags = _O_RDWR | _O_CREAT | _O_APPEND | _O_BINARY;
+      else if (0 == strcmp(priv_mode, "a+t"))
+        flags = _O_RDWR | _O_CREAT | _O_APPEND | _O_TEXT;
+      else if (0 == strcmp(priv_mode, "r+b"))
+        flags = _O_RDWR | _O_BINARY;
+      else if (0 == strcmp(priv_mode, "r+t"))
+        flags = _O_RDWR | _O_TEXT;
+      else if (0 == strcmp(priv_mode, "w+b"))
+        flags = _O_RDWR | _O_CREAT |_O_TRUNC | _O_BINARY;
+      else if (0 == strcmp(priv_mode, "w+t"))
+        flags = _O_RDWR | _O_CREAT |_O_TRUNC | _O_TEXT;
+      else
+      {
+        errno = EINVAL;
+        goto out;
+      }
+    }
+  }
+  if (2 == strlen(priv_mode))
+  {
+    if (('c' == priv_mode[1]) || ('n' == priv_mode[1]))
+      priv_mode[1] = '\0';
+    else
+    {
+      if (0 == strcmp(priv_mode, "a+"))
+        flags = _O_RDWR | _O_CREAT | _O_APPEND;
+      else if (0 == strcmp(priv_mode, "ab"))
+        flags = _O_WRONLY | _O_CREAT | _O_APPEND | _O_BINARY;
+      else if (0 == strcmp(priv_mode, "at"))
+        flags = _O_WRONLY | _O_CREAT | _O_APPEND | _O_TEXT;
+      else if (0 == strcmp(priv_mode, "rb"))
+        flags = _O_RDONLY | _O_BINARY;
+      else if (0 == strcmp(priv_mode, "rt"))
+        flags = _O_RDONLY | _O_TEXT;
+      else if (0 == strcmp(priv_mode, "wb"))
+        flags = _O_WRONLY | _O_CREAT | _O_TRUNC | _O_BINARY;
+      else if (0 == strcmp(priv_mode, "wt"))
+        flags = _O_WRONLY | _O_CREAT | _O_TRUNC | _O_TEXT;
+      else
+      {
+        errno = EINVAL;
+        goto out;
+      }
+    }
+  }
+  if (1 == strlen(priv_mode))
+  {
+    if (0 == strcmp(priv_mode, "a"))
+      flags = _O_WRONLY | _O_CREAT | _O_APPEND;
+    else if (0 == strcmp(priv_mode, "r"))
+      flags = _O_RDONLY;
+    else if (0 == strcmp(priv_mode, "w"))
+      flags = _O_WRONLY | _O_CREAT | _O_TRUNC;
+    else if ( !((0 == strcmp(priv_mode, "c")) || (0 == strcmp(priv_mode, "n"))))
+    {
+      errno = EINVAL;
+      goto out;
+    }
+  }
+
+  hFile = swopen (filename, flags, (_S_IREAD | _S_IWRITE));
+
+  if (INVALID_HANDLE_VALUE == (HANDLE)hFile)
+    /* 'errno' will have already been set by 'swopen()' */
+    retval = NULL;
+  else
+    retval = _fdopen(hFile, mode);
+
+  out:
+  return retval;
+#else
+  return fopen (filename, mode);
+#endif
+}
diff --git a/src/utilfuns/zlib/untgz.c b/src/utilfuns/zlib/untgz.c
index f3f3f56..a9e4a7e 100644
--- a/src/utilfuns/zlib/untgz.c
+++ b/src/utilfuns/zlib/untgz.c
@@ -5,6 +5,8 @@
  * adaptation to Unix by Jean-loup Gailly <jloup@gzip.org>
  */
 
+#include <swopen.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -210,7 +212,7 @@ int makedir (char *newdir)
   if (buffer[len-1] == '/') {
     buffer[len-1] = '\0';
   }
-  if (mkdir(buffer, 0775) == 0)
+  if (swmkdir(buffer, 0775) == 0)
     {
       free(buffer);
       return 1;
@@ -225,7 +227,7 @@ int makedir (char *newdir)
 	p++;
       hold = *p;
       *p = 0;
-      if ((mkdir(buffer, 0775) == -1) && (errno == ENOENT))
+      if ((swmkdir(buffer, 0775) == -1) && (errno == ENOENT))
 	{
 	  fprintf(stderr,"%s: couldn't create directory %s\n",prog,buffer);
 	  free(buffer);
@@ -294,13 +296,13 @@ int untar (gzFile in, const char *dest) {
 	  
 			switch (buffer.header.typeflag) {
 			case DIRTYPE:
-				makedir(fname);
+                swmkdir(fname, 0);
 				break;
 			case REGTYPE:
 			case AREGTYPE:
 				remaining = getoct(buffer.header.size,12);
 				if (remaining) {
-					outfile = fopen(fname,"wb");
+                    outfile = swfopen(fname,"wb");
 					if (outfile == NULL) {
 						// try creating directory
 						char *p = strrchr(fname, '/');
@@ -308,7 +310,7 @@ int untar (gzFile in, const char *dest) {
 							*p = '\0';
 							makedir(fname);
 							*p = '/';
-							outfile = fopen(fname,"wb");
+                            outfile = swfopen(fname,"wb");
 						}
 					}
 /*
@@ -353,7 +355,7 @@ int untar (gzFile in, const char *dest) {
 
 					localt = *localtime(&tartime);
 
-					hFile = CreateFile(fname, GENERIC_READ | GENERIC_WRITE,
+                    hFile = CreateFile(fname, GENERIC_READ | GENERIC_WRITE,
 					0, NULL, OPEN_EXISTING, 0, NULL);
 		  
 					st.wYear = (WORD)localt.tm_year+1900;
