Home » U++ Library support » FileSel&FileList, Path » BUG + FIX: FileSelNative shows default filename as some trash characters
BUG + FIX: FileSelNative shows default filename as some trash characters [message #58798] |
Sat, 03 September 2022 04:19 |
zsolt
Messages: 693 Registered: December 2005 Location: Budapest, Hungary
|
Contributor |
|
|
On windows, using MSC it shows trash, with CLANG: nothing.
To reproduce and test:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
GUI_APP_MAIN
{
FileSelNative fs;
fs
.Type(t_("CSV files"), "*.csv")
.AllFilesType()
.ActiveDir("c:\\tmp")
.DefaultExt("csv")
.Set("ABCDEF.csv");
if(!fs.ExecuteSaveAs())
return;
PromptOK("Filename:&&" + DeQtf(~fs));
}
The fix:
@@ -191,33 +191,33 @@ bool FileSelNative::Execute(bool open, const char *dlgtitle) {
ofn.lpstrInitialDir = W32(activedir);
ofn.lpfnHook = sCenterHook;
int bufsize = ofn.nMaxFile = (multi ? 32000 : _MAX_PATH);
Buffer<char16> buffer(bufsize);
*(ofn.lpstrFile = buffer) = 0;
if(!filename.IsEmpty())
{
- String out;
+ Vector<char16> out;
for(int i = 0; i < filename.GetCount(); i++)
{
if(*ofn.lpstrInitialDir == 0 && FindFile().Search(AppendFileName(GetFileDirectory(filename[i]), "*")))
ofn.lpstrInitialDir = W32(GetFileDirectory(filename[i]));
if(!open || FileExists(filename[i]))
{
String fn = GetFileName(filename[i]);
if(!IsNull(fn))
{
if(multi && fn.Find(' ') >= 0)
- out << W32(String() << '\"' << fn << '\"');
+ out.Append( ToSystemCharsetW('\"' + fn + '\"'));
else
- out << W32(fn);
- out.Cat(0);
+ out.Append(ToSystemCharsetW(fn));
+ out.Add(0);
}
}
}
- int l = min(out.GetLength(), bufsize - 1);
+ int l = min(out.GetCount()*2, bufsize - 1);
memcpy(buffer, out, l + 1);
}
if(dlgtitle)
ofn.lpstrTitle = W32(dlgtitle);
else if(open)
ofn.lpstrTitle = W32(t_("Open.."));
[Updated on: Sat, 03 September 2022 04:20] Report message to a moderator
|
|
|
|
|
Goto Forum:
Current Time: Thu Mar 28 22:40:35 CET 2024
Total time taken to generate the page: 0.01122 seconds
|