Execute Method
| 183 | // Execute Method |
| 184 | // |
| 185 | bool FileDialog::Execute() |
| 186 | { |
| 187 | String strippedFilters; |
| 188 | |
| 189 | U32 filtersCount = StringUnit::getUnitCount(mData.mFilters, "|"); |
| 190 | |
| 191 | for (U32 i = 1; i < filtersCount; ++i) |
| 192 | { |
| 193 | //The first of each pair is the name, which we'll skip because NFD doesn't support named filters atm |
| 194 | String filter = StringUnit::getUnit(mData.mFilters, i, "|"); |
| 195 | |
| 196 | if (!dStrcmp(filter.c_str(), "*.*")) |
| 197 | continue; |
| 198 | |
| 199 | U32 subFilterCount = StringUnit::getUnitCount(filter, ";"); |
| 200 | |
| 201 | //if we have a 'super filter', break it down to sub-options as well |
| 202 | if (subFilterCount > 1) |
| 203 | { |
| 204 | String suffixFilter; |
| 205 | String subFilters; |
| 206 | |
| 207 | for (U32 f = 0; f < subFilterCount; ++f) |
| 208 | { |
| 209 | String subFilter = StringUnit::getUnit(filter, f, ";"); |
| 210 | |
| 211 | suffixFilter += String::ToLower(subFilter) + "," + String::ToUpper(subFilter) + ","; |
| 212 | subFilters += String::ToLower(subFilter) + "," + String::ToUpper(subFilter) + ";"; |
| 213 | } |
| 214 | |
| 215 | suffixFilter = suffixFilter.substr(0, suffixFilter.length() - 1); |
| 216 | suffixFilter += ";"; |
| 217 | |
| 218 | strippedFilters += suffixFilter + subFilters; |
| 219 | } |
| 220 | else //otherwise, just add the filter |
| 221 | { |
| 222 | strippedFilters += String::ToLower(filter) + "," + String::ToUpper(filter) + ";"; |
| 223 | } |
| 224 | |
| 225 | ++i; |
| 226 | if (i < filtersCount - 2) |
| 227 | strippedFilters += String(";"); |
| 228 | } |
| 229 | |
| 230 | //strip the last character, if it's unneeded |
| 231 | if (strippedFilters.endsWith(";")) |
| 232 | { |
| 233 | strippedFilters = strippedFilters.substr(0, strippedFilters.length() - 1); |
| 234 | } |
| 235 | |
| 236 | strippedFilters.replace("*.", ""); |
| 237 | |
| 238 | // Get the current working directory, so we can back up to it once Windows has |
| 239 | // done its craziness and messed with it. |
| 240 | StringTableEntry cwd = Platform::getCurrentDirectory(); |
| 241 | if (mData.mDefaultPath == StringTable->lookup("") || !Platform::isDirectory(mData.mDefaultPath)) |
| 242 | mData.mDefaultPath = cwd; |
no test coverage detected