summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
Diffstat (limited to 'mysys')
-rw-r--r--mysys/mf_cache.c4
-rw-r--r--mysys/mf_tempfile.c3
-rw-r--r--mysys/my_compress.c2
-rw-r--r--mysys/my_os2file64.c58
-rw-r--r--mysys/my_tempnam.c14
5 files changed, 68 insertions, 13 deletions
diff --git a/mysys/mf_cache.c b/mysys/mf_cache.c
index 4b8fc6fed17..85b6b19b328 100644
--- a/mysys/mf_cache.c
+++ b/mysys/mf_cache.c
@@ -38,11 +38,11 @@ static my_bool cache_remove_open_tmp(IO_CACHE *cache __attribute__((unused)),
#else
int length;
if (!(cache->file_name=
- (char*) my_malloc((length=strlen(name)+1),MYF(MY_WME)))
+ (char*) my_malloc((length=strlen(name)+1),MYF(MY_WME))))
{
my_close(cache->file,MYF(0));
cache->file = -1;
- errno=my_error=ENOMEM;
+ errno=my_errno=ENOMEM;
return 1;
}
memcpy(cache->file_name,name,length);
diff --git a/mysys/mf_tempfile.c b/mysys/mf_tempfile.c
index d8a67990a52..262fce64277 100644
--- a/mysys/mf_tempfile.c
+++ b/mysys/mf_tempfile.c
@@ -126,6 +126,9 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
// changing environ variable doesn't work with VACPP
char buffer[256];
sprintf( buffer, "TMP=%s", dir);
+ // remove ending backslash
+ if (buffer[strlen(buffer)-1] == '\\')
+ buffer[strlen(buffer)-1] = '\0';
putenv( buffer);
#else
old_env= (char**) environ;
diff --git a/mysys/my_compress.c b/mysys/my_compress.c
index 3f93e55af9c..f68c7607ed2 100644
--- a/mysys/my_compress.c
+++ b/mysys/my_compress.c
@@ -20,8 +20,8 @@
#include <my_global.h>
#ifdef HAVE_COMPRESS
#include <my_sys.h>
-#include <zlib.h>
#include <m_string.h>
+#include <zlib.h>
/*
** This replaces the packet with a compressed packet
diff --git a/mysys/my_os2file64.c b/mysys/my_os2file64.c
index 8964e562ea1..b7ee40d292e 100644
--- a/mysys/my_os2file64.c
+++ b/mysys/my_os2file64.c
@@ -22,7 +22,6 @@ void _OS2errno( APIRET rc);
longlong _lseek64( int fd, longlong offset, int seektype);
int _lock64( int fd, int locktype, my_off_t start,
my_off_t length, myf MyFlags);
-int _sopen64( const char *name, int oflag, int shflag, int mask);
//
// this class is used to define a global c++ variable, that
@@ -255,7 +254,7 @@ int _lock64( int fd, int locktype, my_off_t start,
return(-1);
}
-int _sopen64( const char *name, int oflag, int shflag, int mask)
+int _sopen( const char *name, int oflag, int shflag, int mask)
{
int fail_errno;
APIRET rc = 0;
@@ -325,17 +324,60 @@ int _sopen64( const char *name, int oflag, int shflag, int mask)
return hf;
}
-inline int open( const char *name, int oflag)
+int read( int fd, void *buffer, unsigned int count)
{
- return _sopen64( name, oflag, OPEN_SHARE_DENYNONE, S_IREAD | S_IWRITE);
+ APIRET rc;
+ ULONG actual;
+
+ rc = DosRead( fd, (PVOID) buffer, count, &actual);
+
+ if (!rc)
+ return( actual);/* NO_ERROR */
+
+ // set errno
+ _OS2errno( rc);
+ // write failed
+ return(-1);
}
-inline int open( const char *name, int oflag, int mask)
+int write( int fd, const void *buffer, unsigned int count)
{
- return _sopen64( name, oflag, OPEN_SHARE_DENYNONE, mask);
+ APIRET rc;
+ ULONG actual;
+
+ rc = DosWrite( fd, (PVOID) buffer, count, &actual);
+
+ if (!rc)
+ return( actual);/* NO_ERROR */
+
+ // set errno
+ _OS2errno( rc);
+ // write failed
+ return(-1);
+}
+
+int close( int fd)
+{
+ APIRET rc;
+ ULONG actual;
+
+ rc = DosClose( fd);
+
+ if (!rc)
+ return( 0);/* NO_ERROR */
+
+ // set errno
+ _OS2errno( rc);
+ // write failed
+ return(-1);
}
-inline int sopen( const char *name, int oflag, int shflag, int mask)
+inline int open( const char *name, int oflag)
+{
+ return sopen( name, oflag, OPEN_SHARE_DENYNONE, S_IREAD | S_IWRITE);
+}
+
+inline int open( const char *name, int oflag, int mask)
{
- return _sopen64( name, oflag, shflag, mask);
+ return sopen( name, oflag, OPEN_SHARE_DENYNONE, mask);
}
diff --git a/mysys/my_tempnam.c b/mysys/my_tempnam.c
index 7da037e8d49..fdaf018af0d 100644
--- a/mysys/my_tempnam.c
+++ b/mysys/my_tempnam.c
@@ -15,6 +15,13 @@
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA */
+/*
+ This function is only used by some old ISAM code.
+ When we remove ISAM support from MySQL, we should also delete this file
+
+ One should instead use the functions in mf_tempfile.c
+*/
+
#include "mysys_priv.h"
#include <m_string.h>
#include "my_static.h"
@@ -95,18 +102,21 @@ my_string my_tempnam(const char *dir, const char *pfx,
// changing environ variable doesn't work with VACPP
char buffer[256];
sprintf( buffer, "TMP=%s", dir);
+ // remove ending backslash
+ if (buffer[strlen(buffer)-1] == '\\')
+ buffer[strlen(buffer)-1] = '\0';
putenv( buffer);
#else
old_env=(char**)environ;
if (dir)
{ /* Don't use TMPDIR if dir is given */
- environ=(const char**)temp_env;
+ environ=(const char**)temp_env; /* May give warning */
temp_env[0]=0;
}
#endif
res=tempnam((char*) dir,(my_string) pfx); /* Use stand. dir with prefix */
#ifndef OS2
- environ=(const char**)old_env;
+ environ=(const char**)old_env; /* May give warning */
#endif
if (!res)
DBUG_PRINT("error",("Got error: %d from tempnam",errno));