Fix snapshot filenames
This commit is contained in:
@@ -1418,31 +1418,43 @@ NEWSYM GetFreeFile
|
|||||||
%else
|
%else
|
||||||
mov esi,fnames+1
|
mov esi,fnames+1
|
||||||
mov ebx,.imagefname
|
mov ebx,.imagefname
|
||||||
.next
|
.end1
|
||||||
mov al,[esi]
|
mov al,[esi]
|
||||||
mov [ebx],al
|
|
||||||
inc esi
|
inc esi
|
||||||
inc ebx
|
cmp al,0
|
||||||
|
jne .end1
|
||||||
|
.end2
|
||||||
|
dec esi
|
||||||
|
mov al,[esi]
|
||||||
cmp al,'.'
|
cmp al,'.'
|
||||||
|
jne .end2
|
||||||
|
mov edx,fnames+1
|
||||||
|
.next
|
||||||
|
mov al,[edx]
|
||||||
|
mov [ebx],al
|
||||||
|
inc edx
|
||||||
|
inc ebx
|
||||||
|
cmp edx,esi
|
||||||
jne .next
|
jne .next
|
||||||
mov esi,ebx
|
mov esi,ebx
|
||||||
mov byte[esi-1],' '
|
mov byte[esi],' '
|
||||||
mov byte[esi],'0'
|
|
||||||
mov byte[esi+1],'0'
|
mov byte[esi+1],'0'
|
||||||
mov byte[esi+2],'0'
|
mov byte[esi+2],'0'
|
||||||
mov byte[esi+3],'.'
|
mov byte[esi+3],'0'
|
||||||
|
mov byte[esi+4],'0'
|
||||||
|
mov byte[esi+5],'.'
|
||||||
cmp ecx,0
|
cmp ecx,0
|
||||||
jne .isbmp
|
jne .isbmp
|
||||||
mov byte[esi+4],'p'
|
mov byte[esi+6],'p'
|
||||||
mov byte[esi+5],'c'
|
mov byte[esi+7],'c'
|
||||||
mov byte[esi+6],'x'
|
mov byte[esi+8],'x'
|
||||||
jmp .doneextselect
|
jmp .doneextselect
|
||||||
.isbmp
|
.isbmp
|
||||||
mov byte[esi+4],'b'
|
mov byte[esi+6],'b'
|
||||||
mov byte[esi+5],'m'
|
mov byte[esi+7],'m'
|
||||||
mov byte[esi+6],'p'
|
mov byte[esi+8],'p'
|
||||||
.doneextselect
|
.doneextselect
|
||||||
mov byte[esi+7],0
|
mov byte[esi+9],0
|
||||||
|
|
||||||
mov word[picnum],0
|
mov word[picnum],0
|
||||||
.findagain
|
.findagain
|
||||||
@@ -1453,24 +1465,28 @@ NEWSYM GetFreeFile
|
|||||||
call Close_File
|
call Close_File
|
||||||
|
|
||||||
inc word[picnum]
|
inc word[picnum]
|
||||||
cmp word[picnum],1000
|
cmp word[picnum],10000
|
||||||
je .nofile
|
je .nofile
|
||||||
|
|
||||||
mov ax,[picnum]
|
mov ax,[picnum]
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
|
mov bx,1000
|
||||||
|
div bx
|
||||||
|
add al,48
|
||||||
|
mov byte[esi+1],al
|
||||||
|
mov ax,dx
|
||||||
|
xor edx,edx
|
||||||
mov bx,100
|
mov bx,100
|
||||||
div bx
|
div bx
|
||||||
mov cl,al
|
add al,48
|
||||||
|
mov byte[esi+2],al
|
||||||
mov ax,dx
|
mov ax,dx
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
mov bx,10
|
mov bx,10
|
||||||
div bx
|
div bx
|
||||||
add cl,48
|
|
||||||
add al,48
|
add al,48
|
||||||
add dl,48
|
add dl,48
|
||||||
mov byte[esi],cl
|
mov byte[esi+3],al
|
||||||
mov byte[esi+1],al
|
mov byte[esi+4],dl
|
||||||
mov byte[esi+2],dl
|
|
||||||
jmp .findagain
|
jmp .findagain
|
||||||
.nofile
|
.nofile
|
||||||
mov edx,.imagefname
|
mov edx,.imagefname
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#ifdef __WIN32DBG__
|
#ifdef __WIN32DBG__
|
||||||
#include <crtdbg.h>
|
#include <crtdbg.h>
|
||||||
@@ -123,12 +124,9 @@ char *generate_filename(void)
|
|||||||
extern char fnames;
|
extern char fnames;
|
||||||
char *filename;
|
char *filename;
|
||||||
char *tmp = &fnames;
|
char *tmp = &fnames;
|
||||||
|
char *tmp2 = 0;
|
||||||
short i=0;
|
short i=0;
|
||||||
#ifdef __WIN32__
|
|
||||||
SYSTEMTIME time;
|
|
||||||
#else
|
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __MSDOS__
|
#ifdef __MSDOS__
|
||||||
filename = (char *)malloc(14);
|
filename = (char *)malloc(14);
|
||||||
@@ -143,45 +141,41 @@ char *generate_filename(void)
|
|||||||
return filename;
|
return filename;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
tmp++; // the first char is the string length
|
tmp++; // the first char is the string length
|
||||||
// removes the path if there is one
|
// removes the path if there is one
|
||||||
while (*tmp!=0) tmp++;
|
while (*tmp!=0) tmp++;
|
||||||
while ((*tmp!='/') && (tmp!=&fnames)) tmp--;
|
while ((*tmp!='/') && (tmp!=&fnames)) tmp--;
|
||||||
tmp++;
|
tmp++;
|
||||||
// allocates enough memory to store the filename
|
// allocates enough memory to store the filename
|
||||||
#ifdef __LINUX__
|
|
||||||
filename = (char *)malloc(strlen(tmp)+10);
|
filename = (char *)malloc(strlen(tmp)+10);
|
||||||
#endif
|
|
||||||
#ifdef __WIN32__
|
|
||||||
filename = (char *)malloc(strlen(tmp)+25);
|
|
||||||
#endif
|
|
||||||
strcpy(filename, tmp);
|
strcpy(filename, tmp);
|
||||||
tmp = filename;
|
|
||||||
while (*tmp!='.') {
|
|
||||||
if (*tmp == ' ') *tmp = '_';
|
|
||||||
tmp++;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __WIN32__
|
tmp = filename+strlen(filename);
|
||||||
/*get system time.*/
|
while (*tmp!='.') tmp--;
|
||||||
GetLocalTime(&time);
|
|
||||||
|
|
||||||
/*make filename from local time*/
|
|
||||||
wsprintf(tmp," %d %02d_%02d %02d-%02d-%02d.png\0", time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond);
|
|
||||||
#endif
|
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
|
tmp2 = filename;
|
||||||
|
while (tmp2<tmp) {
|
||||||
|
if (*tmp2 == ' ') *tmp2 = '_';
|
||||||
|
tmp2++;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*find first unused file*/
|
/*find first unused file*/
|
||||||
|
|
||||||
/*Note: this results in a 1000 image limit!*/
|
/*Note: this results in a 9999 image limit!*/
|
||||||
|
|
||||||
for(i=0;i<10000;i++)
|
for(i=0;i<10000;i++)
|
||||||
{
|
{
|
||||||
sprintf(tmp, "_%04d.png", i);
|
#ifdef __LINUX__
|
||||||
|
sprintf(tmp, "_%04d.png\0", i);
|
||||||
|
#else
|
||||||
|
sprintf(tmp, " %04d.png\0", i);
|
||||||
|
#endif
|
||||||
if(stat(filename, &buf)==-1)
|
if(stat(filename, &buf)==-1)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user