Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
wxString problem
(1/1)
killerbot:
Hi,
From my current active build editor I am getting the filename (easy : cbEditor::GetFileName). Next I want to have the path of it.
So I do a very stupid search on the last '\'. (on winblows that is ...)
int pos = Filename.find(_T('\\'), true), where the second argument means find from the end of the string.
It seems that the second arg is of no importance, I get an identical result as if I would specify false, == search from the start.
My filename is for example : "D:\dir\test.cpp", search from begining (false), or the end (true) both return position 2.
Anyone else stumbled across this problem ??
kind regards,
Lieven
thomas:
http://www.wxwidgets.org/manuals/2.6.2/wx_wxfilename.html#wxfilenamegetpath
killerbot:
how superb !!
THANKS !!! :D
Pecan:
Yep, wxString::find('somechar', true) seems to be broken.
However, wxString::rfind(...) still works. Here's a snippet..
--- Code: --- wxTextCtrl *control = new wxTextCtrl( m_pwxPanel,
-1, //wxWindowID id,
"", //const wxString& value = "",
wxPoint(0,0), //const wxPoint& pos = wxDefaultPosition,
wxSize(500,500) //const wxSize& size = wxDefaultSize, long style = 0,
//const wxValidator& validator = wxDefaultValidator,
//const wxString& name = wxTextCtrlNameStr
);
wxString sPathname=_T("c:\\usr\\proj\\temp\\test.cpp");
size_t lth = sPathname.length();
int pos = sPathname.find('\\', true);
int cpos = sPathname.find('p', true);
int rpos = sPathname.rfind('\\');
*control << " len:" << (int)lth <<" pos:"<< pos ;
*control << " cpos:" << cpos;
*control << " rpos:" << rpos;
//results are: len:25 pos:2 cpos:7 rpos:16
--- End code ---
Thanks for the heads-up Lieven
Pecan
Navigation
[0] Message Index
Go to full version