Changeset 14218
- Timestamp:
- 04/07/08 12:46:38 (3 months ago)
- Files:
-
- branches/1.5/gdal/port/cpl_vsi_mem.cpp (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.5/gdal/port/cpl_vsi_mem.cpp
r13644 r14218 139 139 virtual int Rmdir( const char *pszDirname ); 140 140 virtual char **ReadDir( const char *pszDirname ); 141 static void NormalizePath( CPLString & ); 141 142 }; 142 143 … … 372 373 CPLMutexHolder oHolder( &hMutex ); 373 374 VSIMemFile *poFile; 375 CPLString osFilename = pszFilename; 376 NormalizePath( osFilename ); 374 377 375 378 /* -------------------------------------------------------------------- */ 376 379 /* Get the filename we are opening, create if needed. */ 377 380 /* -------------------------------------------------------------------- */ 378 if( oFileList.find( pszFilename) == oFileList.end() )381 if( oFileList.find(osFilename) == oFileList.end() ) 379 382 poFile = NULL; 380 383 else 381 poFile = oFileList[ pszFilename];384 poFile = oFileList[osFilename]; 382 385 383 386 if( strstr(pszAccess,"w") == NULL && poFile == NULL ) … … 394 397 { 395 398 poFile = new VSIMemFile; 396 poFile->osFilename = pszFilename;399 poFile->osFilename = osFilename; 397 400 oFileList[poFile->osFilename] = poFile; 398 401 poFile->nRefCount++; // for file list … … 432 435 CPLMutexHolder oHolder( &hMutex ); 433 436 434 if( oFileList.find(pszFilename) == oFileList.end() ) 437 CPLString osFilename = pszFilename; 438 NormalizePath( osFilename ); 439 440 if( oFileList.find(osFilename) == oFileList.end() ) 435 441 { 436 442 errno = ENOENT; … … 438 444 } 439 445 440 VSIMemFile *poFile = oFileList[ pszFilename];446 VSIMemFile *poFile = oFileList[osFilename]; 441 447 442 448 memset( pStatBuf, 0, sizeof(VSIStatBufL) ); … … 465 471 CPLMutexHolder oHolder( &hMutex ); 466 472 473 CPLString osFilename = pszFilename; 474 NormalizePath( osFilename ); 475 467 476 VSIMemFile *poFile; 468 477 469 if( oFileList.find( pszFilename) == oFileList.end() )478 if( oFileList.find(osFilename) == oFileList.end() ) 470 479 { 471 480 errno = ENOENT; … … 474 483 else 475 484 { 476 poFile = oFileList[ pszFilename];485 poFile = oFileList[osFilename]; 477 486 478 487 if( --(poFile->nRefCount) == 0 ) 479 488 delete poFile; 480 489 481 oFileList.erase( oFileList.find( pszFilename) );490 oFileList.erase( oFileList.find(osFilename) ); 482 491 483 492 return 0; … … 495 504 CPLMutexHolder oHolder( &hMutex ); 496 505 497 if( oFileList.find(pszPathname) != oFileList.end() ) 506 CPLString osPathname = pszPathname; 507 508 NormalizePath( osPathname ); 509 510 if( oFileList.find(osPathname) != oFileList.end() ) 498 511 { 499 512 errno = EEXIST; … … 503 516 VSIMemFile *poFile = new VSIMemFile; 504 517 505 poFile->osFilename = pszPathname;518 poFile->osFilename = osPathname; 506 519 poFile->bIsDirectory = TRUE; 507 oFileList[ pszPathname] = poFile;520 oFileList[osPathname] = poFile; 508 521 poFile->nRefCount++; /* referenced by file list */ 509 522 … … 531 544 { 532 545 CPLMutexHolder oHolder( &hMutex ); 546 547 CPLString osPath = pszPath; 548 549 NormalizePath( osPath ); 533 550 534 551 std::map<CPLString,VSIMemFile*>::const_iterator iter; 535 552 char **papszDir = NULL; 536 int nPathLen = strlen( pszPath);537 538 if( pszPath[nPathLen-1] == '/' )553 int nPathLen = strlen(osPath); 554 555 if( osPath[nPathLen-1] == '/' ) 539 556 nPathLen--; 540 557 … … 547 564 { 548 565 const char *pszFilePath = iter->second->osFilename.c_str(); 549 if( EQUALN( pszPath,pszFilePath,nPathLen)566 if( EQUALN(osPath,pszFilePath,nPathLen) 550 567 && pszFilePath[nPathLen] == '/' 551 568 && strstr(pszFilePath+nPathLen+1,"/") == NULL ) … … 574 591 575 592 /************************************************************************/ 593 /* NormalizePath() */ 594 /************************************************************************/ 595 596 void VSIMemFilesystemHandler::NormalizePath( CPLString &oPath ) 597 598 { 599 int i, nSize = oPath.size(); 600 601 for( i = 0; i < nSize; i++ ) 602 { 603 if( oPath[i] == '\\' ) 604 oPath[i] = '/'; 605 } 606 607 } 608 609 /************************************************************************/ 576 610 /* VSIInstallLargeFileHandler() */ 577 611 /************************************************************************/
