Question

I have the following c++ code that used to normalize user supplied file path:

wxString orig_path;      
wxFileName res_path(orig_path);
res_path.Normalize(wxPATH_NORM_DOTS);

Refs:

wxFileName::Normalize
wxFileName::Normalize flags

When:

orig_path = "../../dir1/f.csv"

I get annoying error messages:

Error: The path 'f.csv' contains too many ".."!

When:

orig_path = "dir1/../dir2/f.csv"

everything works as expected.

Question

Any way I can suppress those error messages? (silent flag?).
I guess I can do some processing myself before calling Normailze but what's the point? I prefer not to do anything or know anything about orig_path before calling Normailze

Était-ce utile?

La solution

Use wxLogNull. All calls to the log functions during the life time of an object of this class are just ignored. See documentation.

wxLogNull noLogsPlease;
wxString orig_path;      
wxFileName res_path(orig_path);
res_path.Normalize(wxPATH_NORM_DOTS);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top