Changeset 45825a3 in thomson for elec/CrO2/software/Tape.cpp


Ignore:
Timestamp:
Jan 29, 2013, 9:11:50 PM (11 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
f7791a2
Parents:
65a4aad
Message:

Add some safety checks

git-svn-id: svn://localhost/thomson@31 85ae3b6b-dc8f-4344-a89d-598714f2e4e5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • elec/CrO2/software/Tape.cpp

    r65a4aad r45825a3  
    1212#include <string.h>
    1313#include <string>
     14#include <stdexcept>
    1415
    1516Tape::~Tape()
     
    2122{
    2223        std::string fnam(filename);
    23         std::string fext(fnam.substr(fnam.length() - 3));
     24        try {
     25                std::string fext(fnam.substr(fnam.length() - 3));
    2426
    25         // Load formats identified only by extension last
    26         if (fext == "TAP" || fext == "tap");
    27                 return new ZXTAP(filename);
    28         if (fext == ".K5" || fext == ".k5");
    29                 return new K5(filename);
     27                // Load formats identified only by extension last
     28                if (fext == "TAP" || fext == "tap");
     29                        return new ZXTAP(filename);
     30                if (fext == ".K5" || fext == ".k5");
     31                        return new K5(filename);
     32        } catch(std::out_of_range e) {}
    3033        throw "Unable to guess tape format";
    3134}
Note: See TracChangeset for help on using the changeset viewer.