Giter VIP home page Giter VIP logo

Comments (4)

fabzzap avatar fabzzap commented on September 6, 2024

Maybe not the best place for a patch... if you need a better way to submit it tell me (e.g. mailing, or forking the code and pointing to the forked repository)

--- Fileold.cpp Wed Jan 11 07:19:38 2012
+++ File.cpp Sat Oct 20 23:00:41 2012
@@ -38,6 +38,11 @@
#include <unistd.h>
#include <stdio.h>

+#if defined(WIN32) || defined(CYGWIN)
+#include <io.h>
+#include <fcntl.h>
+#endif /* WIN32 || CYGWIN */
+
#include "af_vfs.h"

class FilePOSIX : public File
@@ -84,6 +89,9 @@
int fd = ::open(path, flags, 0666);
if (fd == -1)
return NULL;
+#if defined(WIN32) || defined(CYGWIN)

  • _setmode(fd, _O_BINARY);
    +#endif /* WIN32 || CYGWIN */
    File *file = new FilePOSIX(fd, mode);
    return file;
    }

from audiofile.

mpruett avatar mpruett commented on September 6, 2024

Hi Fabrizio, thanks for catching this problem and for suggesting a fix. The following is slightly simpler; does it seem reasonable to you?

diff --git a/libaudiofile/File.cpp b/libaudiofile/File.cpp
index 36fecdb..089b182 100644
--- a/libaudiofile/File.cpp
+++ b/libaudiofile/File.cpp
@@ -81,6 +81,9 @@ File *File::open(const char *path, File::AccessMode mode)
                flags = O_RDONLY;
        else if (mode == WriteAccess)
                flags = O_CREAT | O_WRONLY | O_TRUNC;
+#if defined(WIN32) || defined(__CYGWIN__)
+       flags |= O_BINARY;
+#endif
        int fd = ::open(path, flags, 0666);
        if (fd == -1)
                return NULL;

from audiofile.

fabzzap avatar fabzzap commented on September 6, 2024

Yes, tested and it works, and it looks like a very clean solution.

from audiofile.

mpruett avatar mpruett commented on September 6, 2024

Thanks for proposing this change. It's checked in as commit 946bf19.

from audiofile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.