TEST_F(MeshVTKLoaderTest, loadBrokenVtuFile_OpenIssue) { setFilename(DataRepository.getFile("mesh/Armadillo_Tetra_4406_for_test_broken.vtu")); EXPECT_FALSE(load()); }
static void resetFilenameToDefault(void) { setFilename("default.profraw", 0); }
void FileContainerBase::handleNotification(Dispatcher<StdString> *oSource, StdString oPath) { UNUSED(oSource); setFilename(oPath); }
TEST_F(MeshVTKLoaderTest, loadBrokenVtkFile_OpenIssue) { setFilename(DataRepository.getFile("mesh/liver_for_test_broken.vtk")); EXPECT_FALSE(load()); }
void MirandaSkinnedDialog::updateFilename() { std::tstring filename; getSkinnedDialogFilename(filename, getSkinName(), getName()); setFilename(filename.c_str()); }
void FileContainerBase::restore(QSettings &oPropertyFile, StdString const &oPrefix) { StdString f = spt::string::fromQt((oPropertyFile.value(spt::string::toQt(oPrefix)+"lastpath", "").toString())); setFilename(f); }
void* MemoryMappedFile::map(const char *filenameIn, unsigned long long &length, int options) { verify( fd == 0 && len == 0 ); // can't open more than once setFilename(filenameIn); FileAllocator::get()->allocateAsap( filenameIn, length ); /* big hack here: Babble uses db names with colons. doesn't seem to work on windows. temporary perhaps. */ char filename[256]; strncpy(filename, filenameIn, 255); filename[255] = 0; { size_t len = strlen( filename ); for ( size_t i=len-1; i>=0; i-- ) { if ( filename[i] == '/' || filename[i] == '\\' ) break; if ( filename[i] == ':' ) filename[i] = '_'; } } updateLength( filename, length ); { DWORD createOptions = FILE_ATTRIBUTE_NORMAL; if ( options & SEQUENTIAL ) createOptions |= FILE_FLAG_SEQUENTIAL_SCAN; DWORD rw = GENERIC_READ | GENERIC_WRITE; fd = CreateFileW( toWideString(filename).c_str(), rw, // desired access FILE_SHARE_WRITE | FILE_SHARE_READ, // share mode NULL, // security OPEN_ALWAYS, // create disposition createOptions , // flags NULL); // hTempl if ( fd == INVALID_HANDLE_VALUE ) { DWORD dosError = GetLastError(); log() << "CreateFileW for " << filename << " failed with " << errnoWithDescription( dosError ) << " (file size is " << length << ")" << " in MemoryMappedFile::map" << endl; return 0; } } mapped += length; { DWORD flProtect = PAGE_READWRITE; //(options & READONLY)?PAGE_READONLY:PAGE_READWRITE; maphandle = CreateFileMappingW(fd, NULL, flProtect, length >> 32 /*maxsizehigh*/, (unsigned) length /*maxsizelow*/, NULL/*lpName*/); if ( maphandle == NULL ) { DWORD dosError = GetLastError(); log() << "CreateFileMappingW for " << filename << " failed with " << errnoWithDescription( dosError ) << " (file size is " << length << ")" << " in MemoryMappedFile::map" << endl; close(); fassertFailed( 16225 ); } } void *view = 0; { scoped_lock lk(mapViewMutex); DWORD access = ( options & READONLY ) ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS; LPVOID thisAddress = getNextMemoryMappedFileLocation( length ); view = MapViewOfFileEx( maphandle, // file mapping handle access, // access 0, 0, // file offset, high and low 0, // bytes to map, 0 == all thisAddress ); // address to place file if ( view == 0 ) { DWORD dosError = GetLastError(); log() << "MapViewOfFileEx for " << filename << " failed with " << errnoWithDescription( dosError ) << " (file size is " << length << ")" << " in MemoryMappedFile::map" << endl; close(); fassertFailed( 16166 ); } } views.push_back(view); memconcept::is(view, memconcept::concept::memorymappedfile, this->filename(), (unsigned) length); len = length; return view; }
void* MemoryMappedFile::map(const char *filenameIn, unsigned long long &length, int options) { verify( fd == 0 && len == 0 ); // can't open more than once setFilename(filenameIn); FileAllocator::get()->allocateAsap( filenameIn, length ); /* big hack here: Babble uses db names with colons. doesn't seem to work on windows. temporary perhaps. */ char filename[256]; strncpy(filename, filenameIn, 255); filename[255] = 0; { size_t len = strlen( filename ); for ( size_t i=len-1; i>=0; i-- ) { if ( filename[i] == '/' || filename[i] == '\\' ) break; if ( filename[i] == ':' ) filename[i] = '_'; } } updateLength( filename, length ); { DWORD createOptions = FILE_ATTRIBUTE_NORMAL; if ( options & SEQUENTIAL ) createOptions |= FILE_FLAG_SEQUENTIAL_SCAN; DWORD rw = GENERIC_READ | GENERIC_WRITE; fd = CreateFileW( toWideString(filename).c_str(), rw, // desired access FILE_SHARE_WRITE | FILE_SHARE_READ, // share mode NULL, // security OPEN_ALWAYS, // create disposition createOptions , // flags NULL); // hTempl if ( fd == INVALID_HANDLE_VALUE ) { DWORD dosError = GetLastError(); log() << "CreateFileW for " << filename << " failed with " << errnoWithDescription( dosError ) << " (file size is " << length << ")" << " in MemoryMappedFile::map" << endl; return 0; } } mapped += length; { DWORD flProtect = PAGE_READWRITE; //(options & READONLY)?PAGE_READONLY:PAGE_READWRITE; maphandle = CreateFileMappingW(fd, NULL, flProtect, length >> 32 /*maxsizehigh*/, (unsigned) length /*maxsizelow*/, NULL/*lpName*/); if ( maphandle == NULL ) { DWORD dosError = GetLastError(); log() << "CreateFileMappingW for " << filename << " failed with " << errnoWithDescription( dosError ) << " (file size is " << length << ")" << " in MemoryMappedFile::map" << endl; close(); fassertFailed( 16225 ); } } void *view = 0; { scoped_lock lk(mapViewMutex); DWORD access = ( options & READONLY ) ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS; int current_retry = 0; while (true) { LPVOID thisAddress = getNextMemoryMappedFileLocation(length); view = MapViewOfFileEx( maphandle, // file mapping handle access, // access 0, 0, // file offset, high and low 0, // bytes to map, 0 == all thisAddress); // address to place file if (view == 0) { DWORD dosError = GetLastError(); ++current_retry; // If we failed to allocate a memory mapped file, try again in case we picked // an address that Windows is also trying to use for some other VM allocations if (dosError == ERROR_INVALID_ADDRESS && current_retry < 5) { continue; } #ifndef _WIN64 // Warn user that if they are running a 32-bit app on 64-bit Windows if (dosError == ERROR_NOT_ENOUGH_MEMORY) { BOOL wow64Process; BOOL retWow64 = IsWow64Process(GetCurrentProcess(), &wow64Process); if (retWow64 && wow64Process) { log() << "This is a 32-bit MongoDB binary running on a 64-bit" " operating system that has run out of virtual memory for" " databases. Switch to a 64-bit build of MongoDB to open" " the databases."; } } #endif log() << "MapViewOfFileEx for " << filename << " at address " << thisAddress << " failed with " << errnoWithDescription(dosError) << " (file size is " << length << ")" << " in MemoryMappedFile::map" << endl; close(); fassertFailed(16166); } break; } } views.push_back(view); len = length; return view; }
bool SimInterior::loadShape(const char* fileName) { // setFilename returns false if the filename is invalid, OR if the filename // is the same as the one already set. In either case, we exit wo/ doing // any work... // if (setFilename(fileName) == false) { return false; } // NOTE: This function is VERY poor on error checking, there are only a few // asserts in ITRInstance(). Maybe restructure to be a bit more robust? // ResourceManager *rm = SimResource::get(manager); Resource<ITRShape> itrShape; bool missionLit; // check if we need to try and find the missionlit ver if( rm->findFile( fileName ) ) { missionLit = missionLitName(); itrShape = rm->load( fileName); } else { if( !missionLitName() ) return( false ); String base = String(fileName); getBaseFilename( base ); if( rm->findFile( base.c_str() ) ) itrShape = rm->load(base.c_str()); missionLit = false; } if( !bool( itrShape ) ) return( false ); // If we make it to here, then all is cool, nuke the old resources... // unloadResources(); ITRInstance* pInstance = new ITRInstance(rm, itrShape, 0); if( missionLit ) pInstance->setMissionLit(); renderImage.instance = pInstance; // Set the geometry for the database and collision image. Note that this // is the highest level of state 0 for the interior. May have to change // the collision image geometry pointer on detail level change, probably // will only change the database pointer on state switches... // updateBoundingBox(); SimContainer* root = NULL; root = findObject(manager,SimRootContainerId,root); root->addObject(this); getInstance()->getAutoStartIDs(animatingLights); SimSet* pITRTimerSet = dynamic_cast<SimSet*>(manager->findObject(SimITRTimerSetId)); if (pITRTimerSet == NULL) manager->addObject(new SimTimerSet(1.0f/15.0f, SimITRTimerSetId)); bool timerSuccess = addToSet(SimITRTimerSetId); AssertFatal(timerSuccess == true, "Could not add to SimITRTimerSet"); return true; }
void* MemoryMappedFile::map(const char *filenameIn, unsigned long long &length, int options) { assert( fd == 0 && len == 0 ); // can't open more than once setFilename(filenameIn); /* big hack here: Babble uses db names with colons. doesn't seem to work on windows. temporary perhaps. */ char filename[256]; strncpy(filename, filenameIn, 255); filename[255] = 0; { size_t len = strlen( filename ); for ( size_t i=len-1; i>=0; i-- ) { if ( filename[i] == '/' || filename[i] == '\\' ) break; if ( filename[i] == ':' ) filename[i] = '_'; } } updateLength( filename, length ); { DWORD createOptions = FILE_ATTRIBUTE_NORMAL; if ( options & SEQUENTIAL ) createOptions |= FILE_FLAG_SEQUENTIAL_SCAN; DWORD rw = GENERIC_READ | GENERIC_WRITE; fd = CreateFile( toNativeString(filename).c_str(), rw, // desired access FILE_SHARE_WRITE | FILE_SHARE_READ, // share mode NULL, // security OPEN_ALWAYS, // create disposition createOptions , // flags NULL); // hTempl if ( fd == INVALID_HANDLE_VALUE ) { DWORD e = GetLastError(); log() << "Create/OpenFile failed " << filename << " errno:" << e << endl; return 0; } } mapped += length; { DWORD flProtect = PAGE_READWRITE; //(options & READONLY)?PAGE_READONLY:PAGE_READWRITE; maphandle = CreateFileMapping(fd, NULL, flProtect, length >> 32 /*maxsizehigh*/, (unsigned) length /*maxsizelow*/, NULL/*lpName*/); if ( maphandle == NULL ) { DWORD e = GetLastError(); // log() call was killing lasterror before we get to that point in the stream log() << "CreateFileMapping failed " << filename << ' ' << errnoWithDescription(e) << endl; close(); return 0; } } void *view = 0; { scoped_lock lk(mapViewMutex); DWORD access = (options&READONLY)? FILE_MAP_READ : FILE_MAP_ALL_ACCESS; view = MapViewOfFile(maphandle, access, /*f ofs hi*/0, /*f ofs lo*/ 0, /*dwNumberOfBytesToMap 0 means to eof*/0); } if ( view == 0 ) { DWORD e = GetLastError(); log() << "MapViewOfFile failed " << filename << " " << errnoWithDescription(e) << ((sizeof(void*)==4)?" (32 bit build)":"") << endl; close(); } else { views.push_back(view); memconcept::is(view, memconcept::concept::memorymappedfile, this->filename(), (unsigned) length); } len = length; return view; }
void rspfHistogramWriter::setOutputName(const rspfString& outputName) { rspfOutputSource::setOutputName(outputName); setFilename(outputName); }