bool copyFtr( const Path& src, const Path &tgt ) { VFSProvider* file = Engine::getVFS("file"); fassert( file != 0 ); DirEntry *entry = file->openDir( src.getFullLocation() ); if( entry == 0 ) { warning( "Can't open directory " + src.getFullLocation() ); return false; } String fname; String module = src.getFile(); Path orig( src ); Path target( tgt ); while( entry->read( fname ) ) { if( fname.startsWith( module ) && fname.endsWith( ".ftt" ) ) { orig.setFilename( fname ); target.setFilename( fname ); if( ! copyFile( orig.get(), target.get() ) ) { warning( "Can't copy source FTT file " + orig.get() ); } } } entry->close(); delete entry; return true; }
bool copyAllResources( Options& options, const Path& from, const Path& tgtPath ) { // do we have an extension filter? bool bHasExt = from.getExtension() != ""; VFSProvider* file = Engine::getVFS("file"); if( file == 0 ) { error( "Can't find FILE resource" ); return false; } DirEntry *entry = file->openDir( from.getFullLocation() ); if( entry == 0 ) { warning( "Can't open directory " + from.getFullLocation() ); return false; } String fname; while( entry->read( fname ) ) { if( fname == ".." || fname == "." ) { continue; } FileStat fs; if ( ! Sys::fal_stats( from.getFullLocation() + "/" + fname, fs ) ) { continue; } if ( fs.m_type == FileStat::t_normal || fs.m_type == FileStat::t_link ) { // do we filter the extension? if( bHasExt ) { if ( ! fname.endsWith( "." + from.getExtension(), true ) ) { continue; } } // TODO: Jail resources under modpath if ( ! copyFile( from.getFullLocation() + "/" + fname, tgtPath.getFullLocation() + "/" + fname ) ) { warning( "Cannot copy resource " + from.getFullLocation() + "/" + fname + " into " + tgtPath.getFullLocation() + "/" + fname ); entry->close(); delete entry; return false; } /* // descend Path nfrom( from ); nfrom.setFullLocation( from.getFullLocation() + "/" + fname ); if( ! copyAllResources( options, nfrom, modPath, tgtPath ) ) { return false; } */ } } entry->close(); delete entry; return true; }
void addPlugins( const Options& options_main, const String& parentModule, const String& path ) { message( "Loading plugin \"" + path +"\" for module " + parentModule ); Path modPath( parentModule ); modPath = modPath.getFullLocation() + "/" + path; // prepare the target plugin path Path outputPath( modPath ); outputPath.setFilename(""); Path mainPath; mainPath.setFullLocation( options_main.m_sMainScriptPath ); relativize( mainPath, outputPath ); outputPath.setFullLocation( options_main.m_sTargetDir +"/"+ outputPath.getLocation() ); // topmost location of the plugin must be if( path.endsWith("*") ) { VFSProvider* file = Engine::getVFS("file"); fassert( file != 0 ); DirEntry *entry = file->openDir( modPath.getFullLocation() ); if( entry == 0 ) { warning( "Can't open plugin directory \"" + modPath.getFullLocation() + "\" for module " + parentModule ); } String fname; while( entry->read( fname ) ) { // binary? if ( fname.endsWith(".fam") ) { // do we have also a source? modPath.setFilename( fname ); modPath.setExtension( "fal" ); FileStat famStats; if( Sys::fal_stats( modPath.get(), famStats ) ) { // we have already a fal that has been transferred or will be transferred later, // so wait for that. continue; // otherwise, go on transferring the source. } // same for ftd modPath.setExtension( "ftd" ); if( Sys::fal_stats( modPath.get(), famStats ) ) { continue; } } else if( fname.endsWith( DllLoader::dllExt() ) ) { //Transfer DLLS as they are. } // source? else if( fname.endsWith( ".fal" ) || fname.endsWith(".ftd") ) { // go on, transfer the source. } else { // we don't know how to manage other plugins continue; } // copy our options, so that transferModule doesn't pollute them Options options( options_main ); options.m_sTargetDir = outputPath.get(); // ok, transfer the thing modPath.setFilename( fname ); transferModules( options, modPath.get() ); } entry->close(); delete entry; } else { // copy our options, so that transferModule doesn't pollute them Options options( options_main ); options.m_sTargetDir = outputPath.get(); transferModules( options, modPath.get() ); } }
bool copyRuntime( const Path& binpath, const Path& tgtpath ) { message( "Searching VSx CRT in " + binpath.getFullLocation() ); // open the binary path in search of "Microsoft.*.CRT" VFSProvider* provider = Engine::getVFS( "file" ); fassert( provider != 0 ); DirEntry* dir = provider->openDir( binpath.getFullLocation() ); if( dir == 0 ) { warning( "Can't search CRT in " + binpath.getFullLocation() ); return false; } String fname; while( dir->read(fname) ) { if( fname.wildcardMatch("Microsoft.*.CRT") ) { // we're done with dir. delete dir; Path source( binpath.getFullLocation() + "/" + fname + "/"); Path target( tgtpath.getFullLocation() + "/" + fname + "/"); // first, create the target path int32 fsStatus; if( ! Sys::fal_mkdir( target.getFullLocation(), fsStatus, true ) ) { warning( "Can't create CRT directory in " + target.getFullLocation() ); return false; } // then copy everything inside it. DirEntry* crtdir = provider->openDir( source.getFullLocation() ); if( crtdir == 0 ) { warning( "Can't read source CRT directory " + source.getFullLocation() ); return false; } //loop copying everything that's not a dir. String sFile; while( crtdir->read( sFile ) ) { if( sFile.startsWith(".") ) continue; source.setFilename( sFile ); target.setFilename( sFile ); if ( ! copyFile( source.get(), target.get() ) ) { delete crtdir; warning( "Can't copy CRT file " + source.get() + " into " + target.get() ); return false; } } return true; } } delete dir; return false; }