1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
/*
* MP3val - a program for MPEG audio file validation
* Copyright (C) 2005-2007 Alexey Kuznetsov (ring0) and Eugen Tikhonov (jetsys)
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "out.h"
#include "crossapi.h"
static int iPrevSize=0;
int GetLastFrameSize() {
return iPrevSize;
}
int WriteToFile(int hFile,char *baseptr,int index,int bytes,int iFileSize) {
int tmp;
int iBytesWritten,iBytesWrittenTotal=0;
if(bytes<0) {
if(iPrevSize) CrossAPI_SetFilePointer(hFile,-iPrevSize,true);
tmp=iPrevSize;
iPrevSize=0;
return tmp;
}
if(iFileSize>=0) {
if(index+bytes>iFileSize) bytes=iFileSize-index;
}
while(iBytesWrittenTotal<bytes) {
if(!CrossAPI_WriteFile(hFile,&baseptr[index+iBytesWrittenTotal],bytes-iBytesWrittenTotal,&iBytesWritten)) {
return -1;
}
iBytesWrittenTotal+=iBytesWritten;
}
iPrevSize=bytes;
return bytes;
}
|