[gdal-dev] How to delete shapefile

Clay, Bruce bclay at ball.com
Wed Jun 17 10:23:29 EDT 2009


Frank:
  Thanks for the information.  I tried to update to a newer version of GDAL (I tried both 1.6.1 and 1.7.0) but the both crash on RegisterAll


In both cases the problem seems to be in the following method

void VSIFileManager::InstallHandler( const std::string& osPrefix,
                                     VSIFilesystemHandler *poHandler )

{
    if( osPrefix == "" )
        Get()->poDefaultHandler = poHandler;
    else
        Get()->oHandlers[osPrefix] = poHandler;
}

The calling methods are passing what appears to be valid strings but the osPrefix contents in this method always seem to be different that the calling method.  One thing that looks odd although it may be valid is using std::string as an array index.  The program will go through InstallHandler a few times before it crashes.  When it does the calling method is passing double quotes yet this method falls to the else condition then crashes.

Are there any settings that need to be changed for the versions after 1.5.3?

Thanks again for your help.

Bruce


The stack trace is shown below.


Stack trace for 1.6.1 is relatively the same but it failed on the GZIPFileSystemHandler (I think that was the name)

Stack trace for 1.7.0

	msvcr80d.dll!cmpDWORD(const void * lhs=0x6973762f, const void * rhs=0x0012e8a0)  + 0x18 bytes	C
 	msvcr80d.dll!unaligned_memcmp(const unsigned char * bLHS=0x69737637, const unsigned char * bRHS=0x0012e8a8, unsigned int siz=8)  + 0x264 bytes	C
 	msvcr80d.dll!memcmp(const void * lhs=0x6973762f, const void * rhs=0x0012e8a0, unsigned int siz=8)  + 0x19a bytes	C
>	msvcp80d.dll!std::char_traits<char>::compare(const char * _First1=0x6973762f, const char * _First2=0x0012e8a0, unsigned int _Count=8)  Line 553 + 0x11 bytes	C++
 	msvcp80d.dll!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::compare(unsigned int _Off=0, unsigned int _N0=12, const char * _Ptr=0x0012e8a0, unsigned int _Count=8)  Line 1978 + 0x2f bytes	C++
 	msvcp80d.dll!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::compare(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _Right="/vsimem/")  Line 1939	C++
 	msvcp80d.dll!std::operator<<char,std::char_traits<char>,std::allocator<char> >(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _Left=<Bad Ptr>, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _Right="/vsimem/")  Line 135 + 0xc bytes	C++
 	OccurrenceTool.exe!std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >::operator()(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _Left="ÍÍÍÍ/vsisubfile/", const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _Right="")  Line 143 + 0xe bytes	C++
 	OccurrenceTool.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,VSIFilesystemHandler *,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,VSIFilesystemHandler *> >,0> >::_Lbound(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _Keyval="")  Line 1174 + 0x19 bytes	C++
 	OccurrenceTool.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,VSIFilesystemHandler *,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,VSIFilesystemHandler *> >,0> >::lower_bound(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _Keyval="")  Line 987 + 0x10 bytes	C++
 	OccurrenceTool.exe!std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,VSIFilesystemHandler *,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,VSIFilesystemHandler *> > >::operator[](const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _Keyval="")  Line 170	C++
 	OccurrenceTool.exe!VSIFileManager::InstallHandler(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & osPrefix="", VSIFilesystemHandler * poHandler=0x023d56e8)  Line 651 + 0x13 bytes	C++
 	OccurrenceTool.exe!VSIInstallMemFileHandler()  Line 694 + 0x48 bytes	C++
 	OccurrenceTool.exe!VSIFileManager::Get()  Line 601	C++
 	OccurrenceTool.exe!VSIFileManager::GetHandler(const char * pszPath=0x01cb4e10)  Line 616 + 0x5 bytes	C++
 	OccurrenceTool.exe!VSIReadDir(const char * pszPath=0x01cb4e10)  Line 63 + 0x9 bytes	C++
 	OccurrenceTool.exe!OGRSFDriverRegistrar::AutoLoadDrivers()  Line 763 + 0x12 bytes	C++
 	OccurrenceTool.exe!OGRRegisterAll()  Line 43	C++
 	OccurrenceTool.exe!GdalWrapper::Initialize()  Line 125 + 0x5 bytes	C++
 	OccurrenceTool.exe!COccurrenceToolView::OnInitialUpdate()  Line 316	C++
 	mfc80d.dll!CWnd::OnWndMsg(unsigned int message=868, unsigned int wParam=0, long lParam=0, long * pResult=0x0012fa2c)  Line 2028	C++
 	mfc80d.dll!CWnd::WindowProc(unsigned int message=868, unsigned int wParam=0, long lParam=0)  Line 1741 + 0x20 bytes	C++
 	mfc80d.dll!AfxCallWndProc(CWnd * pWnd=0x003b96d0, HWND__ * hWnd=0x00d91312, unsigned int nMsg=868, unsigned int wParam=0, long lParam=0)  Line 240 + 0x1c bytes	C++
 	mfc80d.dll!CWnd::SendMessageToDescendants(HWND__ * hWnd=0x00921336, unsigned int message=868, unsigned int wParam=0, long lParam=0, int bDeep=1, int bOnlyPerm=1)  Line 2524	C++
 	mfc80d.dll!CWnd::SendMessageToDescendants(unsigned int message=868, unsigned int wParam=0, long lParam=0, int bDeep=1, int bOnlyPerm=1)  Line 170 + 0x20 bytes	C++
 	mfc80d.dll!CFrameWnd::InitialUpdateFrame(CDocument * pDoc=0x003b90b0, int bMakeVisible=1)  Line 750	C++
 	mfc80d.dll!CDocTemplate::InitialUpdateFrame(CFrameWnd * pFrame=0x003b9140, CDocument * pDoc=0x003b90b0, int bMakeVisible=1)  Line 330	C++
 	mfc80d.dll!CSingleDocTemplate::OpenDocumentFile(const char * lpszPathName=0x00000000, int bMakeVisible=1)  Line 200	C++
 	mfc80d.dll!CDocManager::OnFileNew()  Line 848	C++
 	mfc80d.dll!CWinApp::OnFileNew()  Line 22	C++
 	mfc80d.dll!_AfxDispatchCmdMsg(CCmdTarget * pTarget=0x011a57c8, unsigned int nID=57600, int nCode=0, void (void)* pfn=0x0079e936, void * pExtra=0x00000000, unsigned int nSig=56, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000)  Line 82	C++
 	mfc80d.dll!CCmdTarget::OnCmdMsg(unsigned int nID=57600, int nCode=0, void * pExtra=0x00000000, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000)  Line 381 + 0x27 bytes	C++
 	mfc80d.dll!CWinApp::ProcessShellCommand(CCommandLineInfo & rCmdInfo={...})  Line 24 + 0x20 bytes	C++
 	OccurrenceTool.exe!COccurrenceToolApp::InitInstance()  Line 93 + 0xc bytes	C++
 	mfc80d.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00151f39, int nCmdShow=1)  Line 37 + 0xd bytes	C++
 	OccurrenceTool.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00151f39, int nCmdShow=1)  Line 33	C++
 	OccurrenceTool.exe!__tmainCRTStartup()  Line 589 + 0x35 bytes	C
 	OccurrenceTool.exe!WinMainCRTStartup()  Line 414	C
 	kernel32.dll!7c817067() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]	

-----Original Message-----
From: Frank Warmerdam [mailto:warmerdam at pobox.com] 
Sent: Tuesday, June 16, 2009 7:31 PM
To: Clay, Bruce
Cc: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] How to delete shapefile

Clay, Bruce wrote:
> I am trying to delete a temporary shapefile after running a process with 
> the following code.
...
> The TestCapability always returns FALSE.  If I call DeleteLayer anyway I 
> get an unsupported operation error messege.
> 
> I am using GDAL 1.5.3 with Visual Studio 2005.
>
> Is there an error in my code or a different way to delete a shapefile 
> using GDAL or do I have to go to the operating system and find all of 
> the files that make up the shapefile and delete them that way?

Bruce,

It looks like the DeleteLayer support for the shapefile driver was added
for 1.6.0.  So you need to either upgrade or perhaps just delete the files
yourself with unlink().  Make sure the datasource is closed when you do so.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




This message and any enclosures are intended only for the addressee.  Please  
notify the sender by email if you are not the intended recipient.  If you are  
not the intended recipient, you may not use, copy, disclose, or distribute this  
message or its contents or enclosures to any other person and any such actions  
may be unlawful.  Ball reserves the right to monitor and review all messages  
and enclosures sent to or from this email address.


More information about the gdal-dev mailing list