int VSIMemFilesystemHandler::Rename( const char *pszOldPath, const char *pszNewPath ) { CPLMutexHolder oHolder( &hMutex ); CPLString osOldPath = pszOldPath; CPLString osNewPath = pszNewPath; NormalizePath( osOldPath ); NormalizePath( osNewPath ); if ( osOldPath.compare(osNewPath) == 0 ) return 0; if( oFileList.find(osOldPath) == oFileList.end() ) { errno = ENOENT; return -1; } else { std::map<CPLString,VSIMemFile*>::iterator it = oFileList.find(osOldPath); while (it != oFileList.end() && it->first.ifind(osOldPath) == 0) { const CPLString osRemainder = it->first.substr(osOldPath.size()); if (osRemainder.empty() || osRemainder[0] == '/') { const CPLString osNewFullPath = osNewPath + osRemainder; Unlink_unlocked(osNewFullPath); oFileList[osNewFullPath] = it->second; it->second->osFilename = osNewFullPath; oFileList.erase(it++); } else ++it; } return 0; } }
int VSIMemFilesystemHandler::Unlink( const char * pszFilename ) { CPLMutexHolder oHolder( &hMutex ); return Unlink_unlocked(pszFilename); }