1
0
Fork 0

implement temp file creation function when used without a path (see sf bug #2665465)

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3317
This commit is contained in:
Sebastian Strohhäcker 2009-03-14 16:10:00 +00:00
parent 48edfe5409
commit 88d134b3a9
2 changed files with 11 additions and 9 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2002-2008 The DOSBox Team
* Copyright (C) 2002-2009 The DOSBox Team
*
* 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
@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: dos.cpp,v 1.115 2009-01-14 22:16:00 qbix79 Exp $ */
/* $Id: dos.cpp,v 1.116 2009-03-14 16:10:00 c2woody Exp $ */
#include <stdlib.h>
#include <string.h>
@ -67,8 +67,8 @@ static Bitu DOS_21Handler(void) {
psp.SetStack(RealMake(SegValue(ss),reg_sp-18));
}
char name1[DOSNAMEBUF+1];
char name2[DOSNAMEBUF+1];
char name1[DOSNAMEBUF+2+DOS_NAMELENGTH_ASCII];
char name2[DOSNAMEBUF+2+DOS_NAMELENGTH_ASCII];
switch (reg_ah) {
case 0x01: /* Read character from STDIN, with echo */
{

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: dos_files.cpp,v 1.105 2009-01-24 16:22:55 c2woody Exp $ */
/* $Id: dos_files.cpp,v 1.106 2009-03-14 16:10:00 c2woody Exp $ */
#include <string.h>
#include <stdlib.h>
@ -698,19 +698,21 @@ bool DOS_ForceDuplicateEntry(Bit16u entry,Bit16u newentry) {
}
bool DOS_CreateTempFile(char * const name,Bit16u * entry) {
/* First add random crap to the end of the name and try to open */
size_t namelen=strlen(name);
char * tempname=name+namelen;
if (namelen==0) E_Exit("DOS:Invalid call to CreateTempFile");
else {
if (namelen==0) {
// temp file created in root directory
tempname[0]='\\';
tempname++;
} else {
if ((name[namelen-1]!='\\') && (name[namelen-1]!='/')) {
tempname[0]='\\';
tempname++;
}
}
dos.errorcode=0;
/* add random crap to the end of the name and try to open */
do {
Bit32u i;
for (i=0;i<8;i++) {