[fdo-internals] PATCH: OGR provider does not accept directory
datasources with trailing slash
Kenneth, GEOGRAF A/S
ks at geograf.dk
Fri Apr 4 04:06:34 EDT 2008
I have built an editor for the OGR provider in my MapStudio OS project.
I noticed that the OGR provider does not accept the %MG_DATA_FILE_PATH%
parameter but does accept another path.
After digging around, I found out that OGR rejects directories as
datasources, if they have a trailing slash.
This prevents using the entire repository storage as a datasource, so I
made a small patch that removes a trailing slash, if any.
There should be no compatibility issuses, as none of the other types of
connectionstrings are likely to end with a backslash.
Regards, Kenneth, GEOGRAF A/S
-------------- next part --------------
--- OgrProvider.cpp (revision 3830)
+++ OgrProvider.cpp (working copy)
@@ -176,14 +176,24 @@
const wchar_t* dsw = GetProperty(PROP_NAME_DATASOURCE);
bool readonly = _wcsnicmp(GetProperty(PROP_NAME_READONLY), L"TRUE", 4) == 0;
+ size_t slen = wcslen(dsw);
+ if (dsw[slen - 1] == '\\')
+ wchar_t* tmp = new wchar_t[slen + 1];
+ wcsncpy(tmp, dsw, slen);
+ tmp[slen] = 0;
+ delete tmp;
- printf ("Attempt OGR connect to %s \n", mbdsw);
+ printf ("Attempt OGR connect to %s \n", mbtmp);
printf ("ReadOnly %d\n", (int)readonly);
- m_poDS = OGRSFDriverRegistrar::Open(mbdsw, !readonly);
+ m_poDS = OGRSFDriverRegistrar::Open(mbtmp, !readonly);
if( m_poDS == NULL )
std::string str = "Connect failed: ";
More information about the fdo-internals