| 84 | } |
| 85 | |
| 86 | bool FileSequenceVectorParameter::valueValid( const Object *value, std::string *reason ) const |
| 87 | { |
| 88 | /// we can't call PathParameter::valueValid() because that would do existence checking on |
| 89 | /// our path specifier with the # characters in it, and that would yield the wrong results |
| 90 | /// so we call StringParameter.valueValid and do the rest ourselves. |
| 91 | if ( !StringVectorParameter::valueValid( value ) ) |
| 92 | { |
| 93 | return false; |
| 94 | } |
| 95 | |
| 96 | const StringVectorData *stringVectorDataValue = assertedStaticCast<const StringVectorData>( value ); |
| 97 | const StringVectorData::ValueType &stringVectorValue = stringVectorDataValue->readable(); |
| 98 | |
| 99 | if ( allowEmptyList() && !stringVectorValue.size() ) |
| 100 | { |
| 101 | return true; |
| 102 | } |
| 103 | |
| 104 | for ( StringVectorData::ValueType::const_iterator it = stringVectorValue.begin(); it != stringVectorValue.end(); ++it ) |
| 105 | { |
| 106 | if ( ! boost::regex_match( *it, FileSequence::fileNameValidator() ) ) |
| 107 | { |
| 108 | if ( reason ) |
| 109 | { |
| 110 | *reason = "Value must contain one sequence of at least one # character to specify frame number."; |
| 111 | } |
| 112 | return false; |
| 113 | } |
| 114 | |
| 115 | FileSequencePtr fileSequence = nullptr; |
| 116 | try |
| 117 | { |
| 118 | fileSequence = parseFileSequence( *it ); |
| 119 | } |
| 120 | |
| 121 | catch ( Exception & ) |
| 122 | { |
| 123 | if ( reason ) |
| 124 | { |
| 125 | *reason = "Not a valid file sequence specification"; |
| 126 | } |
| 127 | return false; |
| 128 | } |
| 129 | |
| 130 | assert( fileSequence ); |
| 131 | |
| 132 | if ( m_extensions.size() ) |
| 133 | { |
| 134 | std::string ext = boost::filesystem::path( fileSequence->getFileName() ).extension().string(); |
| 135 | if ( ext.size() && ext[0] == '.' ) |
| 136 | { |
| 137 | ext = ext.substr( 1, ext.size() - 1 ); |
| 138 | } |
| 139 | |
| 140 | if ( std::find( m_extensions.begin(), m_extensions.end(), ext ) == m_extensions.end() ) |
| 141 | { |
| 142 | if ( reason ) |
| 143 | { |