Commit b549c9bb authored by Josh Coalson's avatar Josh Coalson
Browse files

don't use errno on win32

parent 47303c8f
......@@ -17,7 +17,10 @@
* Boston, MA 02111-1307, USA.
*/
#if !defined _MSC_VER && !defined __MINGW32__
/*@@@ don't know how to resolve errno without using LIBC.LIB; must use MSVCRT.LIB only for plugins */
#include <errno.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -295,12 +298,17 @@ static FLAC__bool simple_iterator_prime_input_(FLAC__Metadata_SimpleIterator *it
iterator->is_writable = false;
if(0 == (iterator->file = fopen(iterator->filename, "r+b"))) {
#if !defined _MSC_VER && !defined __MINGW32__
/*@@@ don't know how to resolve errno without using LIBC.LIB; must use MSVCRT.LIB only for plugins */
if(errno == EACCES) {
#endif
if(0 == (iterator->file = fopen(iterator->filename, "rb"))) {
iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE;
return false;
}
#if !defined _MSC_VER && !defined __MINGW32__
}
#endif
else {
iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE;
return false;
......@@ -1906,11 +1914,18 @@ unsigned seek_to_first_metadata_block_(FILE *f)
FLAC__ASSERT(FLAC__STREAM_SYNC_LENGTH == 4);
/* skip any id3v2 tag */
#if !defined _MSC_VER && !defined __MINGW32__
/*@@@ don't know how to resolve errno without using LIBC.LIB; must use MSVCRT.LIB only for plugins */
errno = 0;
#endif
n = fread(buffer, 1, 4, f);
#if !defined _MSC_VER && !defined __MINGW32__
/*@@@ don't know how to resolve errno without using LIBC.LIB; must use MSVCRT.LIB only for plugins */
if(errno)
return 1;
else if(n != 4)
else
#endif
if(n != 4)
return 2;
else if(0 == memcmp(buffer, "ID3", 3)) {
unsigned tag_length = 0;
......@@ -1932,11 +1947,18 @@ unsigned seek_to_first_metadata_block_(FILE *f)
return 1;
/* read the stream sync code */
#if !defined _MSC_VER && !defined __MINGW32__
/*@@@ don't know how to resolve errno without using LIBC.LIB; must use MSVCRT.LIB only for plugins */
errno = 0;
#endif
n = fread(buffer, 1, 4, f);
#if !defined _MSC_VER && !defined __MINGW32__
/*@@@ don't know how to resolve errno without using LIBC.LIB; must use MSVCRT.LIB only for plugins */
if(errno)
return 1;
else if(n != 4)
else
#endif
if(n != 4)
return 2;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment