Archived

This topic is now archived and is closed to further replies.

file type

This topic is 5574 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi im trying to write a file loader for textures where i can send any texture type(filename) into the function. the problem is i dont know how to parse the file name and find out whether its a .tga or .bmp or what not.. anyone know of any resources, articles or stuff for this??? and before anyone burns me for not searching, i have searched google with no decent results and the search function on the forums is disabled...

Share this post


Link to post
Share on other sites
Assuming you want what comes after the last dot in the file name


    
std::string filename, extension;
std::string::size_type backslash, dot;

backslash = filename.find_last_of( '\\' );
if ( backslash == std::string::npos )
backslash = 0;

dot = filename.find_last_of( '.', backslash );

if( dot != std::string::npos )
extension = filename.substr( dot );


extension will be empty if there are no dots in the name.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]


[edited by - Fruny on September 7, 2002 11:40:50 PM]

Share this post


Link to post
Share on other sites