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