| 132 | } |
| 133 | |
| 134 | bool MemoryCardConvertDialog::SetupPicklist() |
| 135 | { |
| 136 | FileSystem::FindResultsArray rootDir; |
| 137 | size_t sizeBytes = 0; |
| 138 | bool typeSet = false; |
| 139 | |
| 140 | m_ui.conversionTypeSelect->clear(); |
| 141 | |
| 142 | switch (m_srcCardInfo.type) |
| 143 | { |
| 144 | case MemoryCardType::File: |
| 145 | m_ui.conversionTypeSelect->addItems({"Folder"}); |
| 146 | SetType(MemoryCardType::Folder, MemoryCardFileType::Unknown, tr("Uses a folder on your PC filesystem, instead of a file. Infinite capacity, while keeping the same compatibility as an 8 MB Memory Card.")); |
| 147 | break; |
| 148 | case MemoryCardType::Folder: |
| 149 | // Compute which file types should be allowed. |
| 150 | FileSystem::FindFiles(m_srcCardInfo.path.c_str(), "*", FLAGS, &rootDir); |
| 151 | |
| 152 | for (auto dirEntry : rootDir) |
| 153 | { |
| 154 | const std::string_view fileName = Path::GetFileName(dirEntry.FileName); |
| 155 | |
| 156 | if (fileName.size() >= 7 && fileName.substr(0, 7).compare("_pcsx2_") == 0) |
| 157 | { |
| 158 | continue; |
| 159 | } |
| 160 | else if (dirEntry.Attributes & FILESYSTEM_FILE_ATTRIBUTE_DIRECTORY) |
| 161 | { |
| 162 | sizeBytes += 512; |
| 163 | } |
| 164 | else |
| 165 | { |
| 166 | size_t toAdd = static_cast<size_t>(dirEntry.Size + (1024 - (dirEntry.Size % 1024))); |
| 167 | sizeBytes += toAdd + 512; // The file content needs to be added, PLUS a directory entry |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | // Finally, round up to the nearest erase block. |
| 172 | sizeBytes += (512 * 16) - (sizeBytes % (512 * 16)); |
| 173 | |
| 174 | if (sizeBytes < CardCapacity::_8_MB) |
| 175 | { |
| 176 | m_ui.conversionTypeSelect->addItem(tr("8 MB File"), 8); |
| 177 | |
| 178 | if (!typeSet) |
| 179 | { |
| 180 | SetType_8(); |
| 181 | typeSet = true; |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | if (sizeBytes < CardCapacity::_16_MB) |
| 186 | { |
| 187 | m_ui.conversionTypeSelect->addItem(tr("16 MB File"), 16); |
| 188 | |
| 189 | if (!typeSet) |
| 190 | { |
| 191 | SetType_16(); |