/****************************************************************** * my_rename ******************************************************************/ int my_rename (const TCHAR *oldname, const TCHAR *newname) { LONG res; char cmd[255]; DebOut("oldname: %s newname %s\n", oldname, newname); res=Rename(oldname, newname); if(res==DOSTRUE) { return 0; } /* ugly hack, as windows rename can move over filesystem borders, * but AROS rename can't. And there seems to be no simple * API to move a file across filesystem borders... * So we use the shell and hope for the best.. */ DebOut("rename failed, try shell copy..\n"); sprintf(cmd, "c:copy from %s to %s MOVE QUIET >NIL:", oldname, newname); DebOut("execute: %s\n", cmd); Execute(cmd, NULL, NULL); if(fsdb_exists(newname)) { /* there is a file, pray, it is the one we copied ;) */ return 0; } SetLastError(IoErr()); DebOut("return -1 (%d)\n", IoErr()); return -1; }
char *fsdb_create_unique_nname (a_inode *base, const char *suggestion) { TCHAR *c; TCHAR tmp[256] = UAEFSDB_BEGINS; int i; _tcsncat (tmp, suggestion, 240); /* replace the evil ones... */ for (i = 0; i < NUM_EVILCHARS; i++) while ((c = _tcschr (tmp, evilchars[i])) != 0) *c = '_'; while ((c = _tcschr (tmp, '.')) != 0) *c = '_'; while ((c = _tcschr (tmp, ' ')) != 0) *c = '_'; for (;;) { TCHAR *p = build_nname (base->nname, tmp); if (!fsdb_exists (p)) { write_log (_T("unique name: %s\n"), p); return p; } xfree (p); /* tmpnam isn't reentrant and I don't really want to hack configure * right now to see whether tmpnam_r is available... */ for (i = 0; i < 8; i++) { tmp[i+8] = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[rand () % 63]; } } }
bool my_resolvesoftlink(TCHAR *linkfile, int size) { struct mystat statbuf; DebOut("linkfile: %s\n", linkfile); if(!fsdb_exists(linkfile)) { DebOut("%s does not exist!\n", linkfile); return FALSE; } fullpath(linkfile, size); DebOut("return : %s\n", linkfile); return TRUE; }
static void fsdb_fixup (FILE *f, TCHAR *buf, int size, a_inode *base) { TCHAR *nname; int ret; if (buf[0] == 0) return; nname = build_nname (base->nname, buf + 5 + 257); ret = fsdb_exists (nname); if (ret) { xfree (nname); return; } TRACE ((_T("uaefsdb '%s' deleted\n"), nname)); /* someone deleted this file/dir outside of emulation.. */ buf[0] = 0; xfree (nname); }