On Windows wave files are opened in binary mode.

git-svn-id: http://voip.null.ro/svn/yate@918 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2006-07-01 00:02:45 +00:00
parent 8e536b76d7
commit bef614c844
3 changed files with 14 additions and 4 deletions

View File

@ -484,7 +484,8 @@ bool File::setBlocking(bool block)
#endif
}
bool File::openPath(const char* name, bool canWrite, bool canRead, bool create, bool append)
bool File::openPath(const char* name, bool canWrite, bool canRead,
bool create, bool append, bool binary)
{
if (!terminate())
return false;
@ -513,6 +514,8 @@ bool File::openPath(const char* name, bool canWrite, bool canRead, bool create,
flags |= O_CREAT;
if (append)
flags |= O_APPEND;
if (binary)
flags |= O_BINARY;
HANDLE h = ::open(name,flags,S_IRWXU);
if (h == invalidHandle()) {
copyError();

View File

@ -136,7 +136,7 @@ WaveSource::WaveSource(const String& file, CallEndpoint* chan, bool autoclose)
start("WaveSource");
return;
}
m_fd = ::open(file.safe(),O_RDONLY|O_NOCTTY);
m_fd = ::open(file.safe(),O_RDONLY|O_NOCTTY|O_BINARY);
if (m_fd < 0) {
Debug(DebugWarn,"Opening '%s': error %d: %s",
file.c_str(), errno, ::strerror(errno));
@ -359,7 +359,7 @@ WaveConsumer::WaveConsumer(const String& file, CallEndpoint* chan, unsigned maxl
m_format = "ilbc20";
else if (file.endsWith(".ilbc30"))
m_format = "ilbc30";
m_fd = ::creat(file.safe(),S_IRUSR|S_IWUSR);
m_fd = ::open(file.safe(),O_WRONLY|O_CREAT|O_TRUNC|O_NOCTTY|O_BINARY,S_IRUSR|S_IWUSR);
if (m_fd < 0)
Debug(DebugWarn,"Creating '%s': error %d: %s",
file.c_str(), errno, ::strerror(errno));

View File

@ -101,6 +101,7 @@ typedef unsigned long in_addr_t;
#define O_RDONLY _O_RDONLY
#define O_WRONLY _O_WRONLY
#define O_APPEND _O_APPEND
#define O_BINARY _O_BINARY
#define O_EXCL _O_EXCL
#define O_CREAT _O_CREAT
#define O_TRUNC _O_TRUNC
@ -147,6 +148,10 @@ typedef int SOCKET;
typedef int HANDLE;
#endif
#ifndef O_BINARY
#define O_BINARY 0
#endif
#if _WORDSIZE == 64
#define FMT64 "%ld"
#define FMT64U "%lu"
@ -3578,9 +3583,11 @@ public:
* @param canRead Open the file for reading
* @param create Create the file if it doesn't exist
* @param append Set the write pointer at the end of an existing file
* @param binary Open the file in binary mode if applicable
* @return True if the file was successfully opened
*/
virtual bool openPath(const char* name, bool canWrite = false, bool canRead = true, bool create = false, bool append = false);
virtual bool openPath(const char* name, bool canWrite = false, bool canRead = true,
bool create = false, bool append = false, bool binary = false);
/**
* Closes the file handle