-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix some encoding issues (mostly on Windows) #4401
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
792e478
Fix file name encoding issues with VST on Windows
PhysSong 9d0aae2
Fix file name encoding issues with ZynAddSubFX on Windows
PhysSong ddcae47
Fix sample file loading on Windows
PhysSong 1af0f08
Fix WAV exporting on Windows
PhysSong 3e538d5
Fix MIDI import encoding issue on Windows
PhysSong 62d505b
Improve STK rawwave path encoding handling
PhysSong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* IoHelper.h - helper functions for file I/O | ||
* | ||
* Copyright (c) 2018 Hyunjin Song <tteu.ingog/at/gmail.com> | ||
* | ||
* This file is part of LMMS - https://lmms.io | ||
* | ||
* 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 (see COPYING); if not, write to the | ||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA. | ||
* | ||
*/ | ||
|
||
|
||
#include "lmmsconfig.h" | ||
|
||
#include <cstdio> | ||
|
||
|
||
#ifdef _WIN32 | ||
#include <windows.h> | ||
|
||
std::wstring toWString(const std::string& s) | ||
{ | ||
std::wstring ret; | ||
int len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), | ||
s.length(), nullptr, 0); | ||
if (len == 0) | ||
{ | ||
return ret; | ||
} | ||
ret.resize(len); | ||
MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s.length(), &ret[0], len); | ||
return ret; | ||
} | ||
#endif | ||
|
||
#ifdef LMMS_BUILD_WIN32 | ||
#include <io.h> | ||
#define F_OPEN_UTF8(a, b) _wfopen(toWString(a).data(), L##b) | ||
#else | ||
#ifdef LMMS_HAVE_UNISTD_H | ||
#include <unistd.h> | ||
#endif | ||
#define F_OPEN_UTF8(a, b) fopen((a).data(), b) | ||
#endif | ||
|
||
int fileToDescriptor(FILE* f, bool closeFile = true) | ||
{ | ||
int fh; | ||
if (f == NULL) {return -1;} | ||
|
||
#ifdef LMMS_BUILD_WIN32 | ||
fh = _dup(_fileno(f)); | ||
#else | ||
fh = dup(fileno(f)); | ||
#endif | ||
|
||
if (closeFile) {fclose(f);} | ||
return fh; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only spotted this now:
fwrite
returns thecount
of elements successfully written, so in this case it will return1
on success, notlen
. Therefore this condition is always leading to a false error message on success (except when coincidentallylen == 1
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Changed to
fwrite( chunk, 1, len, fp )
in 0f3b41f.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also synced into
master
via 170a46e.