Add error codes SFE_ZERO_MAJOR_FORMAT and SFE_ZERO_MINOR_FORMAT.

This commit is contained in:
Erik de Castro Lopo 2007-10-29 14:15:07 +11:00
parent 61472b8599
commit d2f29f5a82
3 changed files with 18 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2007-10-29 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/common.h src/sndfile.c
Add error codes SFE_ZERO_MAJOR_FORMAT and SFE_ZERO_MINOR_FORMAT.
2007-10-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/sd2.c

View File

@ -387,6 +387,8 @@ enum
SFE_MALFORMED_FILE = SF_ERR_MALFORMED_FILE,
SFE_UNSUPPORTED_ENCODING = SF_ERR_UNSUPPORTED_ENCODING,
SFE_ZERO_MAJOR_FORMAT,
SFE_ZERO_MINOR_FORMAT,
SFE_BAD_FILE,
SFE_BAD_FILE_READ,
SFE_OPEN_FAILED,

View File

@ -63,6 +63,8 @@ ErrorStruct SndfileErrors [] =
{ SF_ERR_UNSUPPORTED_ENCODING , "Supported file format but unsupported encoding." },
/* Private error values and their associated strings. */
{ SFE_ZERO_MAJOR_FORMAT , "Error : major format is 0." },
{ SFE_ZERO_MINOR_FORMAT , "Error : major format is 0." },
{ SFE_BAD_FILE , "File does not exist or is not a regular file (possibly a pipe?)." },
{ SFE_BAD_FILE_READ , "File exists but no data could be read." },
{ SFE_OPEN_FAILED , "Could not open file." },
@ -2515,6 +2517,15 @@ psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo)
{ /* If the file is being opened for write or RDWR and the file is currently
** empty, then the SF_INFO struct must contain valid data.
*/
if ((psf->sf.format & SF_FORMAT_TYPEMASK) == 0)
{ error = SFE_ZERO_MAJOR_FORMAT ;
goto error_exit ;
} ;
if ((psf->sf.format & SF_FORMAT_TYPEMASK) == 0)
{ error = SFE_ZERO_MINOR_FORMAT ;
goto error_exit ;
} ;
if (sf_format_check (&(psf->sf)) == 0)
{ error = SFE_BAD_OPEN_FORMAT ;
goto error_exit ;