bool ResourceGUIBackend::LoadCommandLine(int argc,const char** argv) { for(int i=1;i<argc;i++) { if(argv[i][0] == '-') { if(0==strcmp(argv[i],"-l")) { LoadResources(argv[i+1],*resources); i++; } else { printf("Unknown option %s",argv[i]); return 0; } } else { const char* ext=FileExtension(argv[i]); if(0==strcmp(ext,"xml")) { TiXmlDocument doc; if(!doc.LoadFile(argv[i])) { printf("Error loading XML file %s\n",argv[i]); return false; } if(0 == strcmp(doc.RootElement()->Value(),"world")) { XmlWorld xmlWorld; if(!xmlWorld.Load(doc.RootElement(),GetFilePath(argv[i]))) { printf("Error loading world file %s\n",argv[i]); return 0; } if(!xmlWorld.GetWorld(*world)) { printf("Error loading world from %s\n",argv[i]); return 0; } } else if(0 == strcmp(doc.RootElement()->Value(),"resource_library")) { LoadResources(doc.RootElement(),*resources); } else { if(!LoadItem(argv[i],*resources)) return 0; } } else { //try loading into the world const char* ext = FileExtension(argv[i]); if(world->CanLoadElementExt(ext) && world->LoadElement(argv[i])>= 0) { //loaded successfully } else { //failed, now try resource library load if(!LoadItem(argv[i],*resources)) return 0; } } } } return true; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // void CSymbianUnitTestOutputFormatter::ConstructL( const TDesC& aFileName ) { TInt fileNameLength = aFileName.Length(); fileNameLength += 1; // dot length fileNameLength += FileExtension().Length(); HBufC* fileName = HBufC::NewLC( fileNameLength ); fileName->Des() = aFileName; fileName->Des().Append('.'); fileName->Des().Append( FileExtension() ); iOutputWriter = CSymbianUnitTestFileOutputWriter::NewL( *fileName ); CleanupStack::PopAndDestroy( fileName ); }
int RobotWorld::LoadElement(const string& sfn) { const char* fn = sfn.c_str(); const char* ext=FileExtension(fn); if(0==strcmp(ext,"rob") || 0==strcmp(ext,"urdf")) { int res=LoadRobot(fn); if(res<0) { printf("Error loading robot file %s\n",fn); return -1; } return RobotID(res); } else if(0==strcmp(ext,"env") || Geometry::AnyGeometry3D::CanLoadExt(ext)) { int res=LoadTerrain(fn); if(res < 0) { printf("Error loading terrain file %s\n",fn); return -1; } return TerrainID(res); } else if(0==strcmp(ext,"obj")) { int res=LoadRigidObject(fn); if(res<0) { printf("Error loading rigid object file %s\n",fn); return -1; } return RigidObjectID(res); } else { printf("Unknown file extension %s on file %s\n",ext,fn); return -1; } }
int main(int argc, char** argv) { if (argc < 2 || argc > 3) { printf( "USAGE: URDFtoRob robot_file.urdf [optional filename for .rob]\n"); return 0; } string filename; const char* fname; if(argc == 2) filename.assign(argv[1]); else if(argc == 3) filename.assign(argv[2]); StripExtension(filename); filename.append(".rob"); const char* ext = FileExtension(argv[1]); string path = GetFilePath(argv[1]); //temporary -- TODO: make this a flag printf("TEMP: using visualization geometry\n"); URDFConverter::useVisGeom = true; if (0 == strcmp(ext, "urdf")) { Robot robot; robot.LoadURDF(argv[1]); robot.Save(filename.c_str(), path.c_str()); robot.SaveGeometry(path.c_str(),"tri"); } else { printf("Unknown file extension %s on file %s!\nOnly converts URDF to Rob", ext, argv[1]); return 1; } cout<<"Converted "<<argv[1]<<" to "<< filename<<endl; cout << "Done!" << endl; }
IvfVolumeReader::IvfVolumeReader() : DataReaderType<Volume>() , rawFile_("") , filePos_(0) , littleEndian_(true) , dimensions_(size3_t(0)) , format_(nullptr) { addExtension(FileExtension("ivf", "Inviwo ivf file format")); }
inline void SaveQImage ( const QImage& image, string basename="matrix", FileFormat format=PNG ) { DEBUG_CSE string filename = basename + "." + FileExtension(format); QFile file( filename.c_str() ); file.open( QIODevice::WriteOnly ); image.save( &file, QtImageFormat(format) ); }
inline void Ascii( const Matrix<T>& A, std::string basename="matrix", std::string title="" ) { DEBUG_ONLY(CallStackEntry cse("write::Ascii")) std::string filename = basename + "." + FileExtension(ASCII); std::ofstream file( filename.c_str() ); if( !file.is_open() ) RuntimeError("Could not open ",filename); file.setf( std::ios::scientific ); Print( A, title, file ); }
bool FileListBox::MatchFilter(const char *name) const { if (!name) return false; // Special case: no extension means no filtering if (extensions.size() == 0) return true; std::string ext = FileExtension(name); return std::find(extensions.begin(), extensions.end(), ext) != extensions.end(); }
/** * Deserialize everything first then load the data */ void ImageSource::deserialize(IvwDeserializer& d) { isDeserializing_ = true; Processor::deserialize(d); auto extensions = DataReaderFactory::getPtr()->getExtensionsForType<Layer>(); file_.clearNameFilters(); file_.addNameFilter(FileExtension("*", "All Files")); for (auto& ext : extensions) { file_.addNameFilter(ext.description_ + " (*." + ext.extension_ + ")"); } isDeserializing_ = false; load(); }
void VolumeSource::addFileNameFilters() { auto rf = DataReaderFactory::getPtr(); auto extensions = rf->getExtensionsForType<Volume>(); file_.clearNameFilters(); file_.addNameFilter(FileExtension("*", "All Files")); for (auto& ext : extensions) { file_.addNameFilter(ext.description_ + " (*." + ext.extension_ + ")"); } extensions = rf->getExtensionsForType<VolumeVector>(); for (auto& ext : extensions) { file_.addNameFilter(ext.description_ + " (*." + ext.extension_ + ")"); } }
inline void BinaryFlat( const Matrix<T>& A, string basename="matrix" ) { DEBUG_ONLY(CallStackEntry cse("write::BinaryFlat")) string filename = basename + "." + FileExtension(BINARY_FLAT); std::ofstream file( filename.c_str(), std::ios::binary ); if( !file.is_open() ) RuntimeError("Could not open ",filename); if( A.Height() == A.LDim() ) file.write( (char*)A.LockedBuffer(), A.Height()*A.Width()*sizeof(T) ); else for( Int j=0; j<A.Width(); ++j ) file.write( (char*)A.LockedBuffer(0,j), A.Height()*sizeof(T) ); }
void MatrixMarket( const SparseMatrix<T>& A, string basename="matrix" ) { EL_DEBUG_CSE string filename = basename + "." + FileExtension(MATRIX_MARKET); ofstream file( filename.c_str(), std::ios::binary ); if( !file.is_open() ) RuntimeError("Could not open ",filename); // Write the header // ================ { ostringstream os; os << "%%MatrixMarket matrix coordinate "; if( IsComplex<T>::value ) os << "complex "; else os << "real "; os << "general\n"; file << os.str(); } // Write the size line // =================== const Int m = A.Height(); const Int n = A.Width(); const Int numNonzeros = A.NumEntries(); file << BuildString(m," ",n," ",numNonzeros,"\n"); // Write the entries // ================= for( Int e=0; e<numNonzeros; ++e ) { const Int i = A.Row(e); const Int j = A.Col(e); const T value = A.Value(e); if( IsComplex<T>::value ) { file << BuildString(i," ",j," ",RealPart(value)," ",ImagPart(value),"\n"); } else { file << BuildString(i," ",j," ",RealPart(value),"\n"); } } }
void ProcessCommandLine (int argc, char* argv[]) { if ( argc <= 1 ) { DisplayHelp(); exit (0); } else { _tInputFileName = argv [1]; _tInputFileFormat = FileExtension (_tInputFileName); cout << "File : " << _tInputFileName << endl; cout << "Type : " << _tInputFileFormat << endl; } } /* ProcessCommandLine() */
void MatrixMarket( const Matrix<T>& A, string basename="matrix" ) { EL_DEBUG_CSE string filename = basename + "." + FileExtension(MATRIX_MARKET); ofstream file( filename.c_str(), std::ios::binary ); if( !file.is_open() ) RuntimeError("Could not open ",filename); // Write the header // ================ { ostringstream os; os << "%%MatrixMarket matrix array "; if( IsComplex<T>::value ) os << "complex "; else os << "real "; os << "general\n"; file << os.str(); } // Write the size line // =================== const Int m = A.Height(); const Int n = A.Width(); file << BuildString(m," ",n,"\n"); // Write the entries // ================= for( Int j=0; j<n; ++j ) { for( Int i=0; i<m; ++i ) { ostringstream os; os << A.GetRealPart(i,j); if( IsComplex<T>::value ) os << " " << A.GetImagPart(i,j); os << "\n"; file << os.str(); } } }
bool Environment::Load(const char* fn) { const char* ext=FileExtension(fn); if(0==strcmp(ext,"env")) { SimpleFile f(fn); if(!f) { fprintf(stderr,"SimpleFile read failed\n"); return false; } if(f.count("mesh")==0) { fprintf(stderr,"Environment file doesn't contain a mesh file\n"); return false; } if(!f.CheckSize("mesh",1,fn)) return false; string fnPath = GetFilePath(fn); string meshfn = fnPath + f["mesh"][0].AsString(); if(!Meshing::Import(meshfn.c_str(),mesh)) { cout<<"Environment::Load error loading "<<meshfn<<endl; return false; } mesh.InitCollisions(); if(f.count("kFriction")!=0) { if(!f.CheckType("kFriction",PrimitiveValue::Double,fn)) return false; vector<double> values=f.AsDouble("kFriction"); if(values.size() == 1) SetUniformFriction(values[0]); else if(values.size() == mesh.tris.size()) { kFriction = values; } else { fprintf(stderr,"Environment file doesn't contain the right number of friction values\n"); return false; } } return true; } else if(Meshing::CanLoadTriMeshExt(ext)) { if(!Meshing::Import(fn,mesh)) return false; mesh.InitCollisions(); SetUniformFriction(0.5); return true; } }
CImgLayerReader::CImgLayerReader() : DataReaderType<Layer>() { addExtension(FileExtension("raw", "RAW")); #ifdef cimg_use_png addExtension(FileExtension("png", "Portable Network Graphics")); #endif #ifdef cimg_use_jpeg addExtension(FileExtension("jpg", "Joint Photographic Experts Group")); addExtension(FileExtension("jpeg", "Joint Photographic Experts Group")); #endif addExtension(FileExtension("bmp", "Windows bitmap")); #ifdef cimg_use_openexr addExtension(FileExtension("exr", "OpenEXR")); #endif }
bool ImportImage(const char* fn, Image& img) { const char* ext = FileExtension(fn); if(!ext) { fprintf(stderr,"Couldnt detect an extension on image import file %s\n", fn); return false; } if(strlen(ext) > 8) { fprintf(stderr,"Unknown extension \"%s\" on image import file %s\n", ext, fn); return false; } char extbuf[8]; strcpy(extbuf, ext); Lowercase(extbuf); if(0 == strcmp(extbuf, "bit")) { return img.Read(fn); } else if(0 == strcmp(extbuf, "ppm")) { return ImportImagePPM(fn, img); } else if(0 == strcmp(extbuf, "bmp")) { return ImportImageBMP(fn, img); } else if(0 == strcmp(extbuf, "tga")) { return ImportImageTGA(fn, img); } else { #ifdef _WIN32 return ImportImageGDIPlus(fn, img); #else fprintf(stderr,"ImportImage: Unknown file extension \"%s\" on image import file %s\n",extbuf,fn); return false; #endif //_WIN32 } /* { ReportError("Unknown extension \"%s\" on image import file %s", ext, fn); return false; }*/ }
static int CompLink( void ) /***************************/ { int rc; char *p; char *file; char *path; list *itm; char errors_found; void *tmp_env; tool_type utl; int i; if( Flags.be_quiet ) { Fputnl( "option quiet", Fp ); } fputs( DebugOptions[DebugFlag], Fp ); if( StackSize != NULL ) { fputs( "option stack=", Fp ); Fputnl( StackSize, Fp ); } if( Flags.link_for_sys ) { /* 10-jun-91 */ fputs( "system ", Fp ); Fputnl( SystemName, Fp ); } else { #if defined( WCLAXP ) Fputnl( "system ntaxp", Fp ); #elif defined( WCLPPC ) #if defined( __LINUX__ ) Fputnl( "system linuxppc", Fp ); #else Fputnl( "system ntppc", Fp ); #endif #elif defined( WCLMPS ) Fputnl( "system linuxmips", Fp ); #elif defined( WCL386 ) #if defined( __OS2__ ) Fputnl( "system os2v2", Fp ); /* 04-feb-92 */ #elif defined( __NT__ ) Fputnl( "system nt", Fp ); #elif defined( __LINUX__ ) Fputnl( "system linux", Fp ); #else Fputnl( "system dos4g", Fp ); #endif #else if( Flags.windows ) { /* 15-mar-90 */ Fputnl( "system windows", Fp ); } else if( Flags.tiny_model ) { Fputnl( "system com", Fp ); } else if( Flags.link_for_dos ) { Fputnl( "system dos", Fp ); } else if( Flags.link_for_os2 ) { Fputnl( "system os2", Fp ); } else { #if defined( __OS2__ ) Fputnl( "system os2", Fp ); #else Fputnl( "system dos", Fp ); #endif } #endif } /* pass given resources to linker */ for( itm = Res_List; itm != NULL; itm = itm->next ) { fputs( "option resource=", Fp ); FputnlQuoted( itm->item, Fp ); } /* pass given directives to linker */ for( itm = Directive_List; itm != NULL; itm = itm->next ) { Fputnl( itm->item, Fp ); } tmp_env = NULL; if( via_environment && strlen( CC_Opts ) >= 20 ) // 20 to allow wclxxxxx=y tmp_env = makeTmpEnv( CC_Opts ); errors_found = 0; for( itm = Files_List; itm != NULL; itm = itm->next ) { strcpy( Word, itm->item ); utl = SrcName( Word ); /* if no extension, assume .c */ file = GetName( Word ); /* get first matching filename */ path = MakePath( Word ); /* isolate path portion of filespec */ while( file != NULL ) { /* while more filenames: */ strcpy( Word, path ); strcat( Word, file ); if( !FileExtension( Word, OBJ_EXT ) && /* if not .obj or .o, compile */ !FileExtension( Word, OBJ_EXT_SECONDARY ) ) { rc = tool_exec( utl, Word, CC_Opts ); if( rc != 0 ) { errors_found = 1; } p = strrchr( file, '.' ); if( p != NULL ) *p = '\0'; strcpy( Word, file ); } AddName( Word, Fp ); if( Exe_Name[0] == '\0' ) { p = strrchr( Word, '.' ); if( p != NULL ) *p = '\0'; strcpy( Exe_Name, Word ); } #ifdef __UNIX__ MemFree( file ); #endif file = GetName( NULL ); /* get next filename */ } MemFree( path ); } if( tmp_env != NULL ) killTmpEnv( tmp_env ); if( errors_found ) { rc = 1; } else { rc = 0; BuildLinkFile(); if(( Obj_List != NULL || Flags.do_link ) && Flags.no_link == FALSE ) { rc = tool_exec( TYPE_LINK, "@" TEMPFILE, NULL ); if( rc == 0 && Flags.do_cvpack ) { rc = tool_exec( TYPE_PACK, Exe_Name, NULL ); } if( rc != 0 ) { rc = 2; /* return 2 to show Temp_File already closed */ } } } for( i = 0; i < TYPE_MAX; ++i ) { if( tools[i].path != NULL ) { MemFree( tools[i].path ); tools[i].path = NULL; } } return( rc ); }
PVMVolumeWriter::PVMVolumeWriter() : DataWriterType<Volume>() { addExtension(FileExtension("pvm", "PVM file format")); }
#define EL_WRITE_ASCIIMATLAB_HPP namespace El { namespace write { template<typename T> inline void AsciiMatlab ( const Matrix<T>& A, string basename="matrix", string title="matrix" ) { DEBUG_ONLY(CallStackEntry cse("write::AsciiMatlab")) // Empty titles are not legal if( title == "" ) title = "matrix"; string filename = basename + "." + FileExtension(ASCII_MATLAB); ofstream file( filename.c_str() ); if( !file.is_open() ) RuntimeError("Could not open ",filename); file.setf( std::ios::scientific ); file << title << " = [\n"; Print( A, "", file ); file << "];\n"; } } // namespace write } // namespace El #endif // ifndef EL_WRITE_ASCIIMATLAB_HPP
CImgVolumeReader::CImgVolumeReader() : DataReaderType<Volume>() { addExtension(FileExtension("hdr", "Analyze 7.5")); }
static int ParseArgs( int argc, char **argv ) /*********************************************/ { char *p; int wcc_option; int c; int i; list *new_item; initialize_Flags(); DebugFlag = 1; StackSize = NULL; Conventions[0] = 'r'; Conventions[1] = '\0'; preprocess_only = 0; cpp_want_lines = 1; /* NB: wcc and wcl default to 0 here */ cpp_keep_comments = 0; cpp_encrypt_names = 0; cpp_linewrap = NULL; O_Name = NULL; AltOptChar = '-'; /* Suppress '/' as option herald */ while( (c = GetOpt( &argc, argv, #if 0 "b:Cc::D:Ef:g::" "HI:i::k:L:l:M::m:" "O::o:P::QSs::U:vW::wx:yz::", #else "b:CcD:Ef:g::" "HI:i::k:L:l:M::m:" "O::o:P::QSs::U:vW::wx::yz::", #endif EnglishHelp )) != -1 ) { char *Word = ""; int found_mapping = FALSE; for( i = 0; i < sizeof( mappings ) / sizeof( mappings[0] ); i++ ) { option_mapping *m = mappings + i; char *tail = strchr( m->LongName, ':' ); if( c != m->LongName[0] ) continue; if( OptArg == NULL ) { if( m->LongName[1] == '\0' ) { strcat( CC_Opts, " -" ); strcat( CC_Opts, m->WatcomName ); found_mapping = TRUE; break; } /* non-existant argument can't match other cases */ continue; } if( tail != NULL ) { if( !strncmp( OptArg, m->LongName + 1, tail - m->LongName - 1 ) ) { strcat( CC_Opts, " -" ); strcat( CC_Opts, m->WatcomName ); strcat( CC_Opts, OptArg + ( tail - m->LongName - 1) ); found_mapping = TRUE; break; } } else if( !strcmp( OptArg, m->LongName + 1 ) ) { strcat( CC_Opts, " -" ); strcat( CC_Opts, m->WatcomName ); found_mapping = TRUE; break; } } if( found_mapping ) continue; if( OptArg != NULL ) { Word = MemAlloc( strlen( OptArg ) + 6 ); strcpy( Word, OptArg ); } wcc_option = 1; switch( c ) { case 'f': if( !strcmp( Word, "syntax-only" ) ) { c = 'z'; strcpy( Word, "s" ); Flags.no_link = 1; break; } if( !strncmp( Word, "cpp-wrap=", 9 ) ) { MemFree( cpp_linewrap ); Word[7] = 'w'; cpp_linewrap = MemStrDup( Word + 7 ); wcc_option = 0; break; } if( !strcmp( Word, "mangle-cpp" ) ) { cpp_encrypt_names = 1; wcc_option = 0; break; } switch( Word[0] ) { case 'd': /* name of linker directive file */ if( Word[1] == '=' || Word[1] == '#' ) { MakeName( Word, ".lnk" ); /* add extension */ MemFree( Link_Name ); Link_Name = strfdup( Word + 2 ); } else { MemFree( Link_Name ); Link_Name = MemStrDup( TEMPFILE ); } wcc_option = 0; break; case 'm': /* name of map file */ Flags.map_wanted = TRUE; if( Word[1] == '=' || Word[1] == '#' ) { MemFree( Map_Name ); Map_Name = strfdup( Word + 2 ); } wcc_option = 0; break; case 'o': /* name of object file */ /* parse off argument, so we get right filename in linker command file */ p = &Word[1]; if( Word[1] == '=' || Word[1] == '#' ) { ++p; } MemFree( Obj_Name ); Obj_Name = strfdup( p ); /* 08-mar-90 */ break; case 'r': /* name of error report file */ Flags.want_errfile = TRUE; break; } /* avoid passing on unknown options */ wcc_option = 0; break; case 'k': /* stack size option */ if( Word[0] != '\0' ) { MemFree( StackSize ); StackSize = MemStrDup( Word ); } wcc_option = 0; break; /* compiler options that affect the linker */ case 'c': /* compile only */ Flags.no_link = TRUE; wcc_option = 0; break; case 'x': /* change source language */ if( strcmp( Word, "c" ) == 0 ) { Flags.force_c = TRUE; } else if( strcmp( Word, "c++" ) == 0 ) { Flags.force_c_plus = TRUE; } else { Flags.no_link = TRUE; } wcc_option = 0; break; case 'm': if( ( !strncmp( "cmodel=", Word, 7 ) ) && ( Word[8] == '\0' ) ) { if( Word[7] == 't' ) { /* tiny model */ Word[0] = 's'; /* change to small */ Flags.tiny_model = TRUE; } else { Word[0] = Word[7]; } Word[1] = '\0'; break; } if( !strncmp( "regparm=", Word, 8 ) ) { if( !strcmp( Word + 8, "0" ) ) { Conventions[0] = 's'; } else { Conventions[0] = 'r'; } wcc_option = 0; break; } if( !strncmp( "tune=i", Word, 6 ) ) { switch( Word[6] ) { case '0': case '1': case '2': CPU_Class = Word[6]; Conventions[0] = '\0'; break; case '3': case '4': case '5': case '6': CPU_Class = Word[6]; break; default: /* Unknown CPU type --- disable generation of this * option */ CPU_Class = '\0'; } wcc_option = 0; break; } wcc_option = 0; /* dont' pass on unknown options */ break; case 'z': /* 12-jan-89 */ switch( tolower( Word[0] ) ) { case 's': Flags.no_link = TRUE; break; case 'q': Flags.be_quiet = TRUE; break; case 'w': Flags.windows = TRUE; } break; case 'E': preprocess_only = 1; wcc_option = 0; break; case 'P': cpp_want_lines = 0; wcc_option = 0; break; case 'C': cpp_keep_comments = 1; wcc_option = 0; break; case 'o': MemFree( O_Name ); O_Name = strfdup( OptArg ); wcc_option = 0; break; case 'g': if( OptArg == NULL ) { Word = "2"; } else if( !isdigit( OptArg[0] ) ) { c = 'h'; if( strcmp( Word, "w" ) == 0 ) { DebugFlag = 3; } else if( strcmp( Word, "c" ) == 0 ) { /* 02-mar-91 */ Flags.do_cvpack = 1; DebugFlag = 4; } else if( strcmp( Word, "d" ) == 0 ) { DebugFlag = 5; } break; } c = 'd'; parse_d: if( DebugFlag == 0 ) { /* not set by -h yet */ if( strcmp( Word, "1" ) == 0 ) { DebugFlag = 1; } else if( strcmp( Word, "1+" ) == 0 ) { /* 02-mar-91 */ DebugFlag = 2; } else if( strcmp( Word, "2" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "2i" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "2s" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "3" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "3i" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "3s" ) == 0 ) { DebugFlag = 2; } } break; case 'S': Flags.do_disas = TRUE; Flags.no_link = TRUE; if( DebugFlag == 0 ) { c = 'd'; Word = "1"; goto parse_d; } wcc_option = 0; break; case 's': if( OptArg != NULL ) { /* leave -shared to mapping table */ wcc_option = 0; break; } Flags.strip_all = 1; DebugFlag = 0; wcc_option = 0; break; case 'v': Flags.be_quiet = 0; wcc_option = 0; break; case 'W': if( OptArg != NULL && strncmp( OptArg, "l,", 2 ) == 0 ) { AddDirective( OptArg + 2 ); wcc_option = 0; } /* other cases handled by table */ break; case 'I': xlate_fname( Word ); break; case 'b': Flags.link_for_sys = TRUE; MemFree( SystemName ); SystemName = MemStrDup( Word ); /* if Word found in specs.owc, add options from there: */ if( ConsultSpecsFile( Word ) ) { /* all set */ wcc_option = 0; } else { /* not found --- default to bt=<system> */ strcpy( Word, "t=" ); strcat( Word, SystemName ); } break; case 'l': new_item = MemAlloc( sizeof( list ) ); new_item->next = NULL; p = MemAlloc( strlen( OptArg ) + 2 + 1 ); strcpy( p, OptArg ); strcat( p, ".a" ); new_item->item = strfdup( p ); MemFree( p ); ListAppend( &Libs_List, new_item ); wcc_option = 0; break; case 'L': xlate_fname( Word ); fputs( "libpath ", Fp ); Fputnl( Word, Fp ); wcc_option = 0; break; case 'i': /* -include <file> --> -fi=<file> */ if( OptArg == NULL ) { wcc_option = 0; break; } if( !strcmp( OptArg, "nclude" ) ) { c = 'f'; Word = MemReAlloc( Word, strlen( argv[OptInd] ) + 6 ); if( OptInd >= argc - 1 ) { MemFree( cpp_linewrap ); PrintMsg( "Argument of -include missing\n", OptArg ); return( 1 ); } strcpy( Word, "i=" ); strfcat( Word, argv[OptInd] ); argv[OptInd++][0] = '\0'; break; } /* avoid passing un unknown options */ wcc_option = 0; break; case 'M': /* autodepend information for Unix makes */ if( OptArg == NULL ) { wcc_option = 0; break; } c = 'a'; if( !strcmp( OptArg, "D" ) || !strcmp( OptArg, "MD" ) ) { /* NB: only -MMD really matches OW's behaviour, but * for now, let's accept -MD to mean the same */ /* translate to -adt=.o */ strcpy( Word, "dt=.o" ); } else if( !strcmp( OptArg, "F" ) ) { Word = MemReAlloc( Word, strlen( argv[OptInd] ) + 6 ); if( OptInd >= argc - 1 ) { MemFree( cpp_linewrap ); PrintMsg( "Argument of -MF missing\n", OptArg ); return( 1 ); } strcpy( Word, "d=" ); strfcat( Word, argv[OptInd] ); argv[OptInd++][0] = '\0'; } else if( !strcmp( OptArg, "T") ) { Word = MemReAlloc( Word, strlen( argv[OptInd] ) + 6 ); if( OptInd >= argc - 1 ) { MemFree( cpp_linewrap ); PrintMsg( "Argument of -M%s missing\n", OptArg ); return( 1 ); } strcpy( Word, "dt=" ); strcat( Word, argv[OptInd] ); argv[OptInd++][0] = '\0'; } else { /* avoid passing on incompatible options */ wcc_option = 0; } break; } /* don't add linker-specific options */ /* to compiler command line: */ if( wcc_option ) { addccopt( c, Word ); } if( OptArg != NULL ) { MemFree( Word ); Word = NULL; } } if( preprocess_only ) { Flags.no_link = TRUE; if( O_Name == NULL ) { MemFree( Obj_Name ); /* preprocess to stdout by default */ Obj_Name = NULL; } strcat( CC_Opts, " -p" ); if( cpp_encrypt_names ) strcat( CC_Opts, "e" ); if( cpp_want_lines ) strcat( CC_Opts, "l" ); if( cpp_keep_comments ) strcat( CC_Opts, "c" ); if( cpp_linewrap != NULL ) { strcat( CC_Opts, cpp_linewrap ); } } if( CPU_Class ) addccopt( CPU_Class, Conventions ); if( Flags.be_quiet ) addccopt( 'z', "q" ); if( O_Name != NULL ) { if( Flags.no_link && !Flags.do_disas ) { MemFree( Obj_Name ); Obj_Name = O_Name; } else { strcpy( Exe_Name, O_Name ); Flags.keep_exename = 1; MemFree( O_Name ); } O_Name = NULL; } if( Obj_Name != NULL ) { strcat( CC_Opts, " -fo=" ); strcat( CC_Opts, Obj_Name ); } if( !Flags.want_errfile ) { strcat( CC_Opts, " -fr" ); } for( i = 1; i < argc ; i++ ) { Word = argv[i]; if( Word == NULL || Word[0] == '\0' ) /* HBB 20060217: argument was used up */ continue; new_item = MemAlloc( sizeof( list ) ); new_item->next = NULL; new_item->item = strfdup( Word ); if( FileExtension( Word, ".lib" ) || FileExtension( Word, ".a" ) ) { ListAppend( &Libs_List, new_item ); } else { ListAppend( &Files_List, new_item ); } } MemFree( cpp_linewrap ); return( 0 ); }
/* create a new finfo record, open FITS file */ static Finfo FinfoNew(char *fname) { int len; char *e=NULL; char *f=NULL; char *s=NULL; #if FITS2PNG int i; unsigned char header[8]; /* use volatile to make gcc [-Wclobbered] happy (because of setjmp below) */ volatile Finfo finfo; #else Finfo finfo; #endif /* sanity check */ if( !fname ) return NULL; /* return existing finfo, if possible */ if( (finfo=FinfoLookup(fname)) ) return finfo; /* allocate record */ if( !(finfo = (Finfo)xcalloc(sizeof(FinfoRec), 1)) ){ fprintf(stderr, "ERROR: can't allocate rec for image\n"); return NULL; } /* save file name */ finfo->fname = xstrdup(fname); /* check for file type */ if( (s = strrchr(fname, '.')) && !strcasecmp(s, ".png") ){ /* its a PNG */ finfo->ftype = FTYPE_PNG; } else { /* assume FITS type */ finfo->ftype = FTYPE_FITS; } /* open file */ switch(finfo->ftype){ case FTYPE_PNG: #if FITS2PNG /* code taken from "PNG: The Definitive Guide" by Greg Roelofs, Chapter 13 "Reading PNG Images" */ /* set data path */ datapath = getenv("JS9_DATAPATH"); /* look for path of the PNG file */ s = Find(fname, "r", NULL, datapath); if( s && *s ){ if( !(finfo->fp = fopen(s, "rb")) ){ fprintf(stderr, "ERROR: can't open PNG file '%s'\n", fname); goto error; } fread(header, 1, 8, finfo->fp); if( png_sig_cmp(header, 0, 8) ){ fprintf(stderr, "ERROR: not recognized as a PNG file '%s'\n", fname); goto error; } /* initialize stuff */ finfo->png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if( !finfo->png_ptr ){ fprintf(stderr, "ERROR: png_create_read_struct failed '%s'\n", fname); goto error; } finfo->info_ptr = png_create_info_struct(finfo->png_ptr); if( !finfo->info_ptr ){ fprintf(stderr, "ERROR: png_create_info_struct failed '%s'\n", fname); goto error; } if( setjmp(png_jmpbuf(finfo->png_ptr)) ){ fprintf(stderr, "ERROR: during png init_io '%s'\n", fname); goto error; } png_init_io(finfo->png_ptr, finfo->fp); png_set_sig_bytes(finfo->png_ptr, 8); png_read_info(finfo->png_ptr, finfo->info_ptr); /* get the text chunks that come before the image */ if( png_get_text(finfo->png_ptr, finfo->info_ptr, &(finfo->text_ptr), &(finfo->num_text)) > 0 ){ /* process all known PNG keywords */ for(i=0; i<finfo->num_text; i++){ if( !strcmp(finfo->text_ptr[i].key, FITSFILE) ){ finfo->fitsfile = xstrdup(finfo->text_ptr[i].text); /* remove the extension that was used to generate png */ s = strchr(finfo->fitsfile, '['); if( s ){ *s = '\0'; } } } } } else { fprintf(stderr, "ERROR: can't find PNG file '%s' [data path: %s]\n", fname, datapath?datapath:"none"); goto error; } #else fprintf(stderr, "ERROR: for fits2png support, build JS9 using --with-png\n"); goto error; #endif break; /* look for an error */ case FTYPE_FITS: /* fits file can have an extension */ f = FileRoot(fname); /* set data path */ datapath = getenv("JS9_DATAPATH"); /* look for path of the FITS file */ s = Find(f, "r", NULL, datapath); xfree(f); if( s && *s ){ len = strlen(s) + 1; /* construct full path to fits file + extension */ e = FileExtension(fname); if( e ){ len += strlen(e); } finfo->fitsfile = xmalloc(len); strcpy(finfo->fitsfile, s); if( e ){ strcat(finfo->fitsfile, e); } xfree(s); } else { fprintf(stderr, "ERROR: can't find FITS file '%s' [data path: %s]\n", fname, datapath?datapath:"none"); goto error; } break; default: fprintf(stderr, "ERROR: unknown file type '%s'\n", fname); goto error; break; } /* add this finfo to end of list of existing finfos */ FinfoListAdd(&finfohead, finfo); /* return the news */ return finfo; error: /* free up struct and return nothing */ _FinfoFree(finfo); return NULL; }
static int Parse( char *Cmd ) /***************************/ { char opt; char *end; FILE *atfp; char buffer[_MAX_PATH]; char unquoted[_MAX_PATH]; size_t len; char *p; int wcc_option; list *new_item; /* Cmd will always begin with at least one */ /* non-space character if we get this far */ for( ;; ) { Cmd = SkipSpaces( Cmd ); if( *Cmd == '\0' ) break; opt = *Cmd; if( opt == '-' || opt == Switch_Chars[1] ) { Cmd++; } else if( opt != '@' ) { opt = ' '; } end = Cmd; if( *Cmd == '"' ) { end = FindNextWS( end ); } else { end = FindNextWSOrOpt( end, opt, Switch_Chars ); } len = end - Cmd; if( len != 0 ) { if( opt == ' ' ) { /* if filename, add to list */ strncpy( Word, Cmd, len ); Word[len] = '\0'; end = ScanFName( end, len ); UnquoteFName( unquoted, sizeof( unquoted ), Word ); new_item = MemAlloc( sizeof( list ) ); new_item->next = NULL; new_item->item = MemStrDup( unquoted ); if( FileExtension( Word, ".lib" ) ) { ListAppend( &Libs_List, new_item ); } else if( FileExtension( Word, ".res" ) ) { ListAppend( &Res_List, new_item ); } else { ListAppend( &Files_List, new_item ); } } else { /* otherwise, do option */ --len; strncpy( Word, Cmd + 1, len ); Word[len] = '\0'; wcc_option = 1; /* assume it's a wcc option */ switch( tolower( *Cmd ) ) { case 'b': /* possibly -bcl */ if( strnicmp( Word, "cl=", 3 ) == 0 ) { strcat( CC_Opts, " -bt=" ); strcat( CC_Opts, Word+3 ); Flags.link_for_sys = TRUE; MemFree( SystemName ); SystemName = MemStrDup( Word+3 ); wcc_option = 0; } break; case 'f': /* files option */ p = ScanFName( end, len ); switch( tolower( Word[0] ) ) { case 'd': /* name of linker directive file */ if( Word[1] == '=' || Word[1] == '#' ) { end = p; /* remove quotes from target linker control filename */ UnquoteFName( unquoted, sizeof( unquoted ), Word + 2 ); MakeName( unquoted, ".lnk" ); /* add extension */ MemFree( Link_Name ); Link_Name = MemStrDup( unquoted ); } else { MemFree( Link_Name ); Link_Name = MemStrDup( TEMPFILE ); } wcc_option = 0; break; case 'e': /* name of exe file */ if( Word[1] == '=' || Word[1] == '#' ) { end = p; /* remove quotes from target executable filename */ UnquoteFName( unquoted, sizeof( unquoted ), Word + 2 ); strcpy( Exe_Name, unquoted ); } wcc_option = 0; break; case 'i': /* name of forced include file */ end = p; break; case 'm': /* name of map file */ Flags.map_wanted = TRUE; if( Word[1] == '=' || Word[1] == '#' ) { end = p; /* remove quotes from target map filename */ UnquoteFName( unquoted, sizeof( unquoted ), Word + 2 ); MemFree( Map_Name ); Map_Name = MemStrDup( unquoted ); } wcc_option = 0; break; case 'o': /* name of object file */ end = p; /* parse off argument, so we get right filename in linker command file */ p = &Word[1]; if( Word[1] == '=' || Word[1] == '#' ) ++p; /* remove quotes from object name */ UnquoteFName( unquoted, sizeof( unquoted ), p ); MemFree( Obj_Name ); Obj_Name = MemStrDup( unquoted ); break; #if defined( WCLI86 ) || defined( WCL386 ) case 'p': /* floating-point option */ end = p; if( tolower( Word[1] ) == 'c' ) { Flags.math_8087 = 0; } break; #endif default: end = p; break; } break; case 'k': /* stack size option */ if( Word[0] != '\0' ) { MemFree( StackSize ); StackSize = MemStrDup( Word ); } wcc_option = 0; break; case 'l': /* link target option */ switch( (Word[1] << 8) | tolower( Word[0] ) ) { case 'p': Flags.link_for_dos = 0; Flags.link_for_os2 = TRUE; break; case 'r': Flags.link_for_dos = TRUE; Flags.link_for_os2 = 0; break; default: /* 10-jun-91 */ Flags.link_for_sys = TRUE; p = &Word[0]; if( Word[0] == '=' || Word[0] == '#' ) ++p; MemFree( SystemName ); SystemName = MemStrDup( p ); break; } wcc_option = 0; break; case 'x': if( Word[0] == '\0' ) { Flags.two_case = TRUE; wcc_option = 0; } break; case '@': if( Word[0] != '\0' ) { char const * const env = getenv( Word ); if( env != NULL ) { if( handle_environment_variable( env ) ) { return( 1 ); // Recursive call failed } via_environment = TRUE; Cmd = end; continue; } end = ScanFName( end, len ); /* remove quotes from additional linker options file */ UnquoteFName( unquoted, sizeof( unquoted ), Word ); strcpy( Word, unquoted ); MakeName( Word, ".lnk" ); errno = 0; if( (atfp = fopen( Word, "r" )) == NULL ) { PrintMsg( WclMsgs[UNABLE_TO_OPEN_DIRECTIVE_FILE], Word, strerror( errno ) ); return( 1 ); } while( fgets( buffer, sizeof( buffer ), atfp ) != NULL ) { if( strnicmp( buffer, "file ", 5 ) == 0 ) { /* look for names separated by ','s */ p = strchr( buffer, '\n' ); if( p != NULL ) *p = '\0'; AddName( &buffer[5], Fp ); Flags.do_link = TRUE; } else { fputs( buffer, Fp ); } } fclose( atfp ); } wcc_option = 0; break; /* compiler options that affect the linker */ #ifdef WCL386 case '3': case '4': case '5': /* 22-sep-92 */ Conventions = tolower( Word[0] ); break; #endif case 'd': if( DebugFlag == 0 ) { /* not set by -h yet */ if( strcmp( Word, "1" ) == 0 ) { DebugFlag = 1; } else if( strcmp( Word, "1+" ) == 0 ) { /* 02-mar-91 */ DebugFlag = 2; } else if( strcmp( Word, "2" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "2i" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "2s" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "3" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "3i" ) == 0 ) { DebugFlag = 2; } else if( strcmp( Word, "3s" ) == 0 ) { DebugFlag = 2; } } break; case 'h': if( strcmp( Word, "w" ) == 0 ) { DebugFlag = 3; } else if( strcmp( Word, "c" ) == 0 ) { /* 02-mar-91 */ Flags.do_cvpack = 1; DebugFlag = 4; } else if( strcmp( Word, "d" ) == 0 ) { DebugFlag = 5; } break; case 'i': /* include file path */ end = ScanFName( end, len ); break; case 'c': /* compile only */ if( stricmp( Word, "c" ) == 0 ) { Flags.force_c = TRUE; } else if( stricmp( Word, "c++" ) == 0 ) { Flags.force_c_plus = TRUE; } else { Flags.no_link = TRUE; } wcc_option = 0; break; case 'y': if( stricmp( Word, "x" ) == 0 ) { strcat( CC_Opts, " -x" ); wcc_option = 0; } else if( Word[0] == '\0' ) { wcc_option = 0; } break; #if defined( WCLI86 ) || defined( WCL386 ) case 'm': /* memory model */ if( Cmd[1] == 't' || Cmd[1] == 'T' ) { /* tiny model*/ Word[0] = 's'; /* change to small */ Flags.tiny_model = TRUE; } break; #endif case 'p': Flags.no_link = TRUE; break; /* this is a preprocessor option */ case 'q': Flags.be_quiet = TRUE; break; case 'z': /* 12-jan-89 */ switch( tolower( Cmd[1] ) ) { case 's': Flags.no_link = TRUE; break; case 'q': Flags.be_quiet = TRUE; break; #ifdef WCLI86 case 'w': Flags.windows = TRUE; #endif } break; case '"': /* 17-dec-91 */ /* As parameter passing to linker is a special case, we need to pass * whole command instead of first character removed. This allows us * to parse also string literals in AddDirective. */ wcc_option = 0; strncpy( Word, Cmd, ++len ); Word[len] = '\0'; AddDirective( len ); break; } /* don't add linker-specific options */ /* to compiler command line: */ if( wcc_option ) { len = strlen( CC_Opts ); CC_Opts[len++] = ' '; CC_Opts[len++] = opt; CC_Opts[len++] = *Cmd; /* keep original case */ CC_Opts[len] = '\0'; strcat( CC_Opts, Word ); } } Cmd = end; } } return( 0 ); }
MPVMVolumeReader::MPVMVolumeReader() : DataReaderType<Volume>() { addExtension(FileExtension("mpvm", "MPVM (Multiple PVMs) file format")); }
int main(int argc,const char** argv) { if(argc <= 3) { printf("USAGE: ContactPlan [options] world_file configs stance\n"); printf("OPTIONS:\n"); printf("-o filename: the output linear path or multipath (default contactplan.xml)\n"); printf("-p settings: set the planner configuration file\n"); printf("-opt: do optimal planning (do not terminate on the first found solution)\n"); printf("-n iters: set the default number of iterations per step (default 1000)\n"); printf("-t time: set the planning time limit (default infinity)\n"); printf("-m margin: set support polygon margin (default 0)\n"); printf("-r robotindex: set the robot index (default 0)\n"); return 0; } Srand(time(NULL)); int robot = 0; const char* outputfile = "contactplan.xml"; HaltingCondition termCond; string plannerSettings; int i; //parse command line arguments for(i=1;i<argc;i++) { if(argv[i][0]=='-') { if(0==strcmp(argv[i],"-n")) { termCond.maxIters = atoi(argv[i+1]); i++; } else if(0==strcmp(argv[i],"-t")) { termCond.timeLimit = atof(argv[i+1]); i++; } else if(0==strcmp(argv[i],"-opt")) { termCond.foundSolution = false; } else if(0==strcmp(argv[i],"-p")) { if(!GetFileContents(argv[i+1],plannerSettings)) { printf("Unable to load planner settings file %s\n",argv[i+1]); return 1; } i++; } else if(0==strcmp(argv[i],"-r")) { robot = atoi(argv[i+1]); i++; } else if(0==strcmp(argv[i],"-m")) { gSupportPolygonMargin = atof(argv[i+1]); i++; } else if(0==strcmp(argv[i],"-o")) { outputfile = argv[i+1]; i++; } else { printf("Invalid option %s\n",argv[i]); return 1; } } else break; } if(i+3 < argc) { printf("USAGE: ContactPlan [options] world_file configs stance\n"); return 1; } if(i+3 > argc) { printf("Warning: extra arguments provided\n"); } const char* worldfile = argv[i]; const char* configsfile = argv[i+1]; const char* stancefile = argv[i+2]; //Read in the world file XmlWorld xmlWorld; RobotWorld world; if(!xmlWorld.Load(worldfile)) { printf("Error loading world XML file %s\n",worldfile); return 1; } if(!xmlWorld.GetWorld(world)) { printf("Error loading world file %s\n",worldfile); return 1; } vector<Config> configs; { //Read in the configurations specified in configsfile ifstream in(configsfile); if(!in) { printf("Error opening configs file %s\n",configsfile); return false; } while(in) { Config temp; in >> temp; if(in) configs.push_back(temp); } if(configs.size() < 2) { printf("Configs file does not contain 2 or more configs\n"); return 1; } in.close(); } Stance stance; { //read in the stance specified by stancefile ifstream in(stancefile,ios::in); in >> stance; if(!in) { printf("Error loading stance file %s\n",stancefile); return 1; } in.close(); } //If the stance has no contacts, use ContactPlan. Otherwise, use StancePlan bool ignoreContactForces = false; if(NumContactPoints(stance)==0) { printf("No contact points in stance, planning without stability constraints\n"); ignoreContactForces = true; } //set up the command line, store it into the MultiPath settings string cmdline; cmdline = argv[0]; for(int i=1;i<argc;i++) { cmdline += " "; cmdline += argv[i]; } MultiPath path; path.settings["robot"] = world.robots[robot].name; path.settings["command"] = cmdline; //begin planning bool feasible = true; Config qstart = world.robots[robot].robot->q; for(size_t i=0;i+1<configs.size();i++) { MilestonePath mpath; bool res = false; if(ignoreContactForces) res = ContactPlan(world,robot,configs[i],configs[i+1],stance,mpath,termCond,plannerSettings); else res = StancePlan(world,robot,configs[i],configs[i+1],stance,mpath,termCond,plannerSettings); if(!res) { printf("Planning from stance %d to %d failed\n",i,i+1); path.sections.resize(path.sections.size()+1); path.SetStance(stance,path.sections.size()-1); path.sections.back().milestones[0] = configs[i]; path.sections.back().milestones[1] = configs[i+1]; break; } else { path.sections.resize(path.sections.size()+1); path.sections.back().milestones.resize(mpath.NumMilestones()); path.SetStance(stance,path.sections.size()-1); for(int j=0;j<mpath.NumMilestones();j++) path.sections.back().milestones[j] = mpath.GetMilestone(j); qstart = path.sections.back().milestones.back(); } } if(feasible) printf("Path planning success! Saving to %s\n",outputfile); else printf("Path planning failure. Saving placeholder path to %s\n",outputfile); const char* ext = FileExtension(outputfile); if(ext && 0==strcmp(ext,"path")) { printf("Converted to linear path format\n"); LinearPath lpath; Convert(path,lpath); ofstream f(outputfile,ios::out); lpath.Save(f); f.close(); } else path.Save(outputfile); return 0; }
static int CompLink( void ) /***************************/ { int rc; char *p; char *file; char *path; list *itm; char errors_found; tool_type utl; int i; if( Flags.be_quiet ) { Fputnl( "option quiet", Fp ); } fputs( DebugOptions[DebugFlag], Fp ); if( StackSize != NULL ) { fputs( "option stack=", Fp ); Fputnl( StackSize, Fp ); } if( Flags.link_for_sys ) { fputs( "system ", Fp ); Fputnl( SystemName, Fp ); } else if( Flags.is32bit ) { #if defined(__OS2__) Fputnl( "system os2v2", Fp ); #elif defined(__NT__) Fputnl( "system nt", Fp ); #elif defined(__LINUX__) Fputnl( "system linux", Fp ); if( !Flags.strip_all ) Fputnl( "option exportall", Fp ); #else Fputnl( "system dos4g", Fp ); #endif } else { if( Flags.windows ) { /* 15-mar-90 */ Fputnl( "system windows", Fp ); } else if( Flags.tiny_model ) { Fputnl( "system com", Fp ); } else { #if defined(__OS2__) Fputnl( "system os2", Fp ); #else Fputnl( "system dos", Fp ); #endif } } for( itm = Directive_List; itm != NULL; itm = itm->next ) { Fputnl( itm->item, Fp ); } Word = MemAlloc( MAX_CMD ); errors_found = 0; for( itm = Files_List; itm != NULL; itm = itm->next ) { strcpy( Word, itm->item ); utl = SrcName( Word ); /* if no extension, assume .c */ file = GetName( Word ); /* get first matching filename */ path = MakePath( Word ); /* isolate path portion of filespec */ while( file != NULL ) { /* while more filenames: */ strcpy( Word, path ); strcat( Word, file ); if( !FileExtension( Word, OBJ_EXT ) && // if not .obj or .o, compile !FileExtension( Word, OBJ_EXT_SECONDARY ) ) { rc = tool_exec( utl, Word, CC_Opts ); if( rc != 0 ) { errors_found = 1; } p = strrchr( file, '.' ); if( p != NULL ) { *p = '\0'; } strcpy( Word, file ); } AddName( Word, Fp ); if( Obj_List != NULL && Flags.do_disas ) { char *sfile; char *ofile; ofile = MemAlloc( strlen( file ) + 6 ); strcpy( ofile, file ); if( Exe_Name[0] != '\0' ) { /* have "-S -o output.name" */ sfile = Exe_Name; } else { if( FileExtension( Word, OBJ_EXT ) || FileExtension( Word, OBJ_EXT_SECONDARY ) ) { p = strrchr( file, '.' ); if( p != NULL ) { *p = '\0'; } strcpy( Word, file ); } else { /* wdis needs extension */ strcat( ofile, Obj_Name ); } sfile = Word; strcat( Word, ".s" ); } memmove( sfile + 3, sfile, strlen( sfile ) + 1 ); sfile[0] = '-'; sfile[1] = 'l'; sfile[2] = '='; rc = tool_exec( TYPE_DIS, ofile, sfile ); MemFree( ofile ); } if( Exe_Name[0] == '\0' ) { #ifdef __UNIX__ strcpy( Exe_Name, OUTPUTFILE ); Flags.keep_exename = 1; #else p = strrchr( Word, '.' ); if( p != NULL ) { *p = '\0'; } strcpy( Exe_Name, Word ); #endif } #ifdef __UNIX__ MemFree( file ); #endif file = GetName( NULL ); /* get next filename */ } MemFree( path ); } if( errors_found ) { rc = 1; } else { rc = 0; BuildLinkFile(); if(( Obj_List != NULL || Flags.do_link ) && Flags.no_link == FALSE ) { rc = tool_exec( TYPE_LINK, "@" TEMPFILE, NULL ); if( rc == 0 && Flags.do_cvpack ) { rc = tool_exec( TYPE_PACK, Exe_Name, NULL ); } if( rc != 0 ) { rc = 2; /* return 2 to show Temp_File already closed */ } } } if( Word != NULL ) { MemFree( Word ); Word = NULL; } for( i = 0; i < TYPE_MAX; ++i ) { if( tools[i].path != NULL ) { MemFree( tools[i].path ); tools[i].path = NULL; } } return( rc ); }
FileExtension FilePath::Extension() const{ return FileExtension(m_impl->path.GetExt()); }