Merge branch 'develop' into cffi-unicode-fixes
This commit is contained in:
@@ -81,7 +81,7 @@ namespace lime {
|
||||
|
||||
static int VorbisFile_BufferClose (VorbisFile_Buffer* src) {
|
||||
|
||||
free (src);
|
||||
delete src;
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -154,8 +154,8 @@ namespace lime {
|
||||
|
||||
if (ov_open_callbacks (buffer, vorbisFile, NULL, 0, VORBIS_FILE_BUFFER_CALLBACKS) != 0) {
|
||||
|
||||
free (buffer);
|
||||
free (vorbisFile);
|
||||
delete buffer;
|
||||
delete vorbisFile;
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -178,7 +178,7 @@ namespace lime {
|
||||
|
||||
if (ov_open_callbacks (file, vorbisFile, NULL, 0, VORBIS_FILE_FILE_CALLBACKS) != 0) {
|
||||
|
||||
free (vorbisFile);
|
||||
delete vorbisFile;
|
||||
lime::fclose (file);
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -1287,6 +1287,13 @@ namespace lime {
|
||||
|
||||
}
|
||||
|
||||
static int seek_callback (void *userp, curl_off_t offset, int origin) {
|
||||
if (origin == SEEK_SET) {
|
||||
readBytesPosition[userp] = offset;
|
||||
return CURL_SEEKFUNC_OK;
|
||||
}
|
||||
return CURL_SEEKFUNC_CANTSEEK;
|
||||
}
|
||||
|
||||
static size_t read_callback (void *buffer, size_t size, size_t nmemb, void *userp) {
|
||||
|
||||
@@ -1634,6 +1641,9 @@ namespace lime {
|
||||
readBytesPosition[handle] = 0;
|
||||
readBytesRoot[handle] = new ValuePointer (bytes);
|
||||
|
||||
// seek function is needed to support redirects
|
||||
curl_easy_setopt (easy_handle, CURLOPT_SEEKFUNCTION, seek_callback);
|
||||
curl_easy_setopt (easy_handle, CURLOPT_SEEKDATA, handle);
|
||||
code = curl_easy_setopt (easy_handle, CURLOPT_READFUNCTION, read_callback);
|
||||
curl_easy_setopt (easy_handle, CURLOPT_READDATA, handle);
|
||||
|
||||
@@ -2061,6 +2071,8 @@ namespace lime {
|
||||
readBytesPosition[handle] = 0;
|
||||
readBytesRoot[handle] = new ValuePointer ((vobj*)bytes);
|
||||
|
||||
curl_easy_setopt (easy_handle, CURLOPT_SEEKFUNCTION, seek_callback);
|
||||
curl_easy_setopt (easy_handle, CURLOPT_SEEKDATA, handle);
|
||||
code = curl_easy_setopt (easy_handle, CURLOPT_READFUNCTION, read_callback);
|
||||
curl_easy_setopt (easy_handle, CURLOPT_READDATA, handle);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <stdio.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
|
||||
#include <tinyfiledialogs.h>
|
||||
|
||||
@@ -71,10 +72,29 @@ namespace lime {
|
||||
|
||||
#ifdef HX_WINDOWS
|
||||
|
||||
std::wstring temp (L"*.");
|
||||
const wchar_t* filters[] = { filter ? (temp + *filter).c_str () : NULL };
|
||||
std::vector<std::wstring> filters_vec;
|
||||
if (filter) {
|
||||
std::wstring temp (L"*.");
|
||||
std::wstring line;
|
||||
std::wstringstream ss(*filter);
|
||||
while(std::getline(ss, line, L',')) {
|
||||
filters_vec.push_back(temp + line);
|
||||
}
|
||||
}
|
||||
|
||||
const wchar_t* path = tinyfd_openFileDialogW (title ? title->c_str () : 0, defaultPath ? defaultPath->c_str () : 0, filter ? 1 : 0, filter ? filters : NULL, NULL, 0);
|
||||
const int numFilters = filter ? filters_vec.size() : 1;
|
||||
const wchar_t **filters = new const wchar_t*[numFilters];
|
||||
if (filter && numFilters > 0) {
|
||||
for (int index = 0; index < numFilters; index++) {
|
||||
filters[index] = const_cast<wchar_t*>(filters_vec[index].c_str());
|
||||
}
|
||||
} else {
|
||||
filters[0] = NULL;
|
||||
}
|
||||
|
||||
const wchar_t* path = tinyfd_openFileDialogW (title ? title->c_str () : 0, defaultPath ? defaultPath->c_str () : 0, filter ? numFilters : 0, filter ? filters : NULL, NULL, 0);
|
||||
|
||||
delete[] filters;
|
||||
|
||||
if (path && std::wcslen(path) > 0) {
|
||||
|
||||
@@ -89,16 +109,29 @@ namespace lime {
|
||||
std::string* _filter = wstring_to_string (filter);
|
||||
std::string* _defaultPath = wstring_to_string (defaultPath);
|
||||
|
||||
const char* filters[] = { NULL };
|
||||
|
||||
std::vector<std::string> filters_vec;
|
||||
if (_filter) {
|
||||
|
||||
_filter->insert (0, "*.");
|
||||
filters[0] = _filter->c_str ();
|
||||
|
||||
std::string line;
|
||||
std::stringstream ss(*_filter);
|
||||
while(std::getline(ss, line, ',')) {
|
||||
line.insert (0, "*.");
|
||||
filters_vec.push_back(line);
|
||||
}
|
||||
}
|
||||
|
||||
const char* path = tinyfd_openFileDialog (_title ? _title->c_str () : NULL, _defaultPath ? _defaultPath->c_str () : NULL, _filter ? 1 : 0, _filter ? filters : NULL, NULL, 0);
|
||||
const int numFilters = _filter ? filters_vec.size() : 1;
|
||||
const char **filters = new const char*[numFilters];
|
||||
if (_filter && numFilters > 0) {
|
||||
for (int index = 0; index < numFilters; index++) {
|
||||
filters[index] = const_cast<char*>(filters_vec[index].c_str());
|
||||
}
|
||||
} else {
|
||||
filters[0] = NULL;
|
||||
}
|
||||
|
||||
const char* path = tinyfd_openFileDialog (_title ? _title->c_str () : NULL, _defaultPath ? _defaultPath->c_str () : NULL, _filter ? numFilters : 0, _filter ? filters : NULL, NULL, 0);
|
||||
|
||||
delete[] filters;
|
||||
|
||||
if (_title) delete _title;
|
||||
if (_filter) delete _filter;
|
||||
@@ -125,10 +158,29 @@ namespace lime {
|
||||
|
||||
#ifdef HX_WINDOWS
|
||||
|
||||
std::wstring temp (L"*.");
|
||||
const wchar_t* filters[] = { filter ? (temp + *filter).c_str () : NULL };
|
||||
std::vector<std::wstring> filters_vec;
|
||||
if (filter) {
|
||||
std::wstring temp (L"*.");
|
||||
std::wstring line;
|
||||
std::wstringstream ss(*filter);
|
||||
while(std::getline(ss, line, L',')) {
|
||||
filters_vec.push_back(temp + line);
|
||||
}
|
||||
}
|
||||
|
||||
const wchar_t* paths = tinyfd_openFileDialogW (title ? title->c_str () : 0, defaultPath ? defaultPath->c_str () : 0, filter ? 1 : 0, filter ? filters : NULL, NULL, 1);
|
||||
const int numFilters = filter ? filters_vec.size() : 1;
|
||||
const wchar_t **filters = new const wchar_t*[numFilters];
|
||||
if (filter && numFilters > 0) {
|
||||
for (int index = 0; index < numFilters; index++) {
|
||||
filters[index] = const_cast<wchar_t*>(filters_vec[index].c_str());
|
||||
}
|
||||
} else {
|
||||
filters[0] = NULL;
|
||||
}
|
||||
|
||||
const wchar_t* paths = tinyfd_openFileDialogW (title ? title->c_str () : 0, defaultPath ? defaultPath->c_str () : 0, filter ? numFilters : 0, filter ? filters : NULL, NULL, 1);
|
||||
|
||||
delete[] filters;
|
||||
|
||||
if (paths) {
|
||||
|
||||
@@ -142,16 +194,29 @@ namespace lime {
|
||||
std::string* _filter = wstring_to_string (filter);
|
||||
std::string* _defaultPath = wstring_to_string (defaultPath);
|
||||
|
||||
const char* filters[] = { NULL };
|
||||
|
||||
std::vector<std::string> filters_vec;
|
||||
if (_filter) {
|
||||
|
||||
_filter->insert (0, "*.");
|
||||
filters[0] = _filter->c_str ();
|
||||
|
||||
std::string line;
|
||||
std::stringstream ss(*_filter);
|
||||
while(std::getline(ss, line, ',')) {
|
||||
line.insert (0, "*.");
|
||||
filters_vec.push_back(line);
|
||||
}
|
||||
}
|
||||
|
||||
const char* paths = tinyfd_openFileDialog (_title ? _title->c_str () : NULL, _defaultPath ? _defaultPath->c_str () : NULL, _filter ? 1 : 0, _filter ? filters : NULL, NULL, 1);
|
||||
const int numFilters = _filter ? filters_vec.size() : 1;
|
||||
const char **filters = new const char*[numFilters];
|
||||
if (_filter && numFilters > 0) {
|
||||
for (int index = 0; index < numFilters; index++) {
|
||||
filters[index] = const_cast<char*>(filters_vec[index].c_str());
|
||||
}
|
||||
} else {
|
||||
filters[0] = NULL;
|
||||
}
|
||||
|
||||
const char* paths = tinyfd_openFileDialog (_title ? _title->c_str () : NULL, _defaultPath ? _defaultPath->c_str () : NULL, _filter ? numFilters : 0, _filter ? filters : NULL, NULL, 1);
|
||||
|
||||
delete[] filters;
|
||||
|
||||
if (_title) delete _title;
|
||||
if (_filter) delete _filter;
|
||||
|
||||
Reference in New Issue
Block a user