Fixed sound for non ascii systems

This commit is contained in:
WolverinDEV 2020-03-19 18:25:41 +01:00
parent 9c3c0250c1
commit 6b3b717cf5
2 changed files with 4 additions and 2 deletions

View File

@ -8,7 +8,7 @@ import * as paths from "path";
namespace audio.sounds {
export async function play_sound(file: sound.SoundFile) : Promise<void> {
await new Promise((resolve, reject) => {
let pathname = paths.dirname(location.pathname);
let pathname = paths.dirname(decodeURIComponent(location.pathname));
if(pathname[0] === '/' && pathname[2] === ':') //e.g.: /C:/test...
pathname = pathname.substr(1);
const path = paths.join(pathname, file.path);

View File

@ -4,6 +4,7 @@
#include "./wav.h"
#include "../../logger.h"
#include <filesystem>
using namespace tc::audio::file;
@ -37,7 +38,8 @@ WAVReader::~WAVReader() {
}
FileOpenResult WAVReader::open_file(std::string& error) {
this->is_.open(this->file_path_, std::ifstream::in | std::ifstream::binary);
//C:\Users\%D0%9E%D0%BB%D0%B5%D0%B3\AppData\Roaming\TeaClient\tmp\ui\release_1584625323\index.html
this->is_.open(std::filesystem::u8path(this->file_path_), std::ifstream::in | std::ifstream::binary);
if(!this->is_) {
error = tr("failed to open file");
return FileOpenResult::OPEN_RESULT_ERROR;