From 3daf91bc3ca7d75bd6ba8686fb7970ebee8e1895 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Mon, 9 Dec 2002 21:11:43 +0000 Subject: [PATCH] Updates for mbfile move --- mbfido/mbfmove.c | 44 +++++++++++++++++++------------------------- mbfido/mbfutil.c | 6 +++--- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/mbfido/mbfmove.c b/mbfido/mbfmove.c index da3a83f6..7a2a8007 100644 --- a/mbfido/mbfmove.c +++ b/mbfido/mbfmove.c @@ -52,7 +52,7 @@ extern int do_quiet; /* Suppress screen output */ */ void Move(int From, int To, char *File) { - char *frompath, *topath, *temp1, *temp2, *fromlink, *tolink; + char *frompath, *topath, *temp1, *temp2, *fromlink, *tolink, *fromthumb, *tothumb; struct FILERecord fdb; FILE *fp1, *fp2; int rc = FALSE, Found = FALSE; @@ -113,10 +113,13 @@ void Move(int From, int To, char *File) frompath = xstrcpy(area.Path); frompath = xstrcat(frompath, (char *)"/"); - frompath = xstrcat(frompath, fdb.LName); + frompath = xstrcat(frompath, fdb.Name); fromlink = xstrcpy(area.Path); fromlink = xstrcat(fromlink, (char *)"/"); - fromlink = xstrcat(fromlink, fdb.Name); + fromlink = xstrcat(fromlink, fdb.LName); + fromthumb = xstrcpy(area.Path); + fromthumb = xstrcat(fromthumb, (char *)"/."); + fromthumb = xstrcat(fromthumb, fdb.Name); /* * Check Destination area @@ -142,10 +145,13 @@ void Move(int From, int To, char *File) topath = xstrcpy(area.Path); topath = xstrcat(topath, (char *)"/"); - topath = xstrcat(topath, fdb.LName); + topath = xstrcat(topath, fdb.Name); tolink = xstrcpy(area.Path); tolink = xstrcat(tolink, (char *)"/"); - tolink = xstrcat(tolink, fdb.Name); + tolink = xstrcat(tolink, fdb.LName); + tothumb = xstrcpy(area.Path); + tothumb = xstrcat(tothumb, (char *)"/."); + tothumb = xstrcat(tothumb, fdb.Name); temp2 = calloc(PATH_MAX, sizeof(char)); sprintf(temp2, "%s/fdb/fdb%d.temp", getenv("MBSE_ROOT"), From); @@ -164,30 +170,16 @@ void Move(int From, int To, char *File) if (strcmp(fdb.LName, File) && strcmp(fdb.Name, File)) fwrite(&fdb, sizeof(fdb), 1, fp2); else { - if (strcmp(fdb.Name, fdb.LName)) - rc = AddFile(fdb, To, topath, frompath, tolink); - else - rc = AddFile(fdb, To, topath, frompath, NULL); + rc = AddFile(fdb, To, topath, frompath, tolink); if (rc) { - /* - * Remove old 8.3 name - */ - if (strcmp(fdb.Name, fdb.LName)) - unlink(fromlink); + unlink(fromlink); + unlink(frompath); + /* * Try to move thumbnail if it exists */ - unlink(frompath); - free(frompath); - free(topath); - frompath = xstrcpy(area.Path); - frompath = xstrcat(frompath, (char *)"/."); - frompath = xstrcat(frompath, File); - topath = xstrcpy(area.Path); - topath = xstrcat(topath, (char *)"/."); - topath = xstrcat(topath, File); - if (file_exist(frompath, R_OK) == 0) { - file_mv(frompath, topath); + if (file_exist(fromthumb, R_OK) == 0) { + file_mv(fromthumb, tothumb); } } } @@ -226,8 +218,10 @@ void Move(int From, int To, char *File) free(temp2); free(frompath); free(fromlink); + free(fromthumb); free(topath); free(tolink); + free(tothumb); } diff --git a/mbfido/mbfutil.c b/mbfido/mbfutil.c index cce9ca5d..5ea2a159 100644 --- a/mbfido/mbfutil.c +++ b/mbfido/mbfutil.c @@ -328,10 +328,10 @@ int AddFile(struct FILERecord fdb, int Area, char *DestPath, char *FromPath, cha } chmod(DestPath, 0644); if (LinkPath) { - if ((rc = link(DestPath, LinkPath))) { - WriteError("Can't create link %s", LinkPath); + if ((rc = symlink(DestPath, LinkPath))) { + WriteError("Can't create symbolic link %s", LinkPath); if (!do_quiet) - printf("Can't create link %s, %s\n", LinkPath, strerror(rc)); + printf("Can't create symbolic link %s, %s\n", LinkPath, strerror(rc)); unlink(DestPath); return FALSE; }