summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
Diffstat (limited to 'mysys')
-rw-r--r--mysys/mf_getdate.c6
-rw-r--r--mysys/my_open.c1
-rw-r--r--mysys/my_redel.c41
3 files changed, 40 insertions, 8 deletions
diff --git a/mysys/mf_getdate.c b/mysys/mf_getdate.c
index 627789dc802..f01d1d7633a 100644
--- a/mysys/mf_getdate.c
+++ b/mysys/mf_getdate.c
@@ -23,6 +23,7 @@
/*
If flag & 1 Return date and time
If flag & 2 Return short date format YYMMDD
+ if flag & 4 Return time in HHMMDD format.
*/
@@ -56,4 +57,9 @@ void get_date(register my_string to, int flag, time_t date)
start_time->tm_hour,
start_time->tm_min,
start_time->tm_sec);
+ else if (flag & 4)
+ sprintf(strend(to),"%02d%02d%02d",
+ start_time->tm_hour,
+ start_time->tm_min,
+ start_time->tm_sec);
} /* get_date */
diff --git a/mysys/my_open.c b/mysys/my_open.c
index 1f9d5cc3bae..85df8a46b53 100644
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@ -97,6 +97,7 @@ int my_close(File fd, myf MyFlags)
pthread_mutex_lock(&THR_LOCK_open);
if ((err = close(fd)))
{
+ DBUG_PRINT("error",("Got error %d on close",err));
my_errno=errno;
if (MyFlags & (MY_FAE | MY_WME))
my_error(EE_BADCLOSE, MYF(ME_BELL+ME_WAITTANG),my_filename(fd),errno);
diff --git a/mysys/my_redel.c b/mysys/my_redel.c
index da03b026c9f..0cc17481dab 100644
--- a/mysys/my_redel.c
+++ b/mysys/my_redel.c
@@ -18,6 +18,7 @@
#define USES_TYPES /* sys/types is included */
#include "mysys_priv.h"
#include <my_dir.h>
+#include <m_string.h>
#include "mysys_err.h"
#if defined(HAVE_SYS_UTIME_H)
#include <sys/utime.h>
@@ -30,21 +31,45 @@ struct utimbuf {
};
#endif
- /* Rename with copy stat form old file */
- /* Copy stats from old file to new file, deletes orginal and */
- /* changes new file name to old file name */
+ /*
+ Rename with copy stat form old file
+ Copy stats from old file to new file, deletes orginal and
+ changes new file name to old file name
+
+ if MY_REDEL_MAKE_COPY is given, then the orginal file
+ is renamed to org_name-'current_time'.BAK
+ */
+
+#define REDEL_EXT ".BAK"
int my_redel(const char *org_name, const char *tmp_name, myf MyFlags)
{
+ int error=1;
DBUG_ENTER("my_redel");
DBUG_PRINT("my",("org_name: '%s' tmp_name: '%s' MyFlags: %d",
org_name,tmp_name,MyFlags));
- if (my_copystat(org_name,tmp_name,MyFlags) < 0 ||
- my_delete(org_name,MyFlags) ||
- my_rename(tmp_name,org_name,MyFlags))
- DBUG_RETURN(1);
- DBUG_RETURN(0);
+ if (my_copystat(org_name,tmp_name,MyFlags) < 0)
+ goto end;
+ if (MyFlags & MY_REDEL_MAKE_BACKUP)
+ {
+ char name_buff[FN_REFLEN+20];
+ char ext[20];
+ ext[0]='-';
+ get_date(ext+1,2+4,(time_t) 0);
+ strmov(strend(ext),REDEL_EXT);
+ if (my_rename(org_name, fn_format(name_buff, org_name, "", ext, 2),
+ MyFlags))
+ goto end;
+ }
+ else if (my_delete(org_name,MyFlags))
+ goto end;
+ if (my_rename(tmp_name,org_name,MyFlags))
+ goto end;
+
+ error=0;
+end:
+ DBUG_RETURN(error);
} /* my_redel */