| 158 | } |
| 159 | |
| 160 | std::string ModuleContext::GetDataFile(const std::string &filename) const |
| 161 | { |
| 162 | // compute the module storage path |
| 163 | #ifdef US_PLATFORM_WINDOWS |
| 164 | static const char separator = '\\'; |
| 165 | #else |
| 166 | static const char separator = '/'; |
| 167 | #endif |
| 168 | |
| 169 | std::string baseStoragePath = ModuleSettings::GetStoragePath(); |
| 170 | if (baseStoragePath.empty()) return std::string(); |
| 171 | if (baseStoragePath != d->module->baseStoragePath) |
| 172 | { |
| 173 | d->module->baseStoragePath = baseStoragePath; |
| 174 | d->module->storagePath.clear(); |
| 175 | } |
| 176 | |
| 177 | if (d->module->storagePath.empty()) |
| 178 | { |
| 179 | char buf[50]; |
| 180 | snprintf(buf, sizeof(buf), "%ld", d->module->info.id); |
| 181 | d->module->storagePath = baseStoragePath + separator + buf + "_" + d->module->info.name + separator; |
| 182 | } |
| 183 | return d->module->storagePath + filename; |
| 184 | } |
| 185 | |
| 186 | |
| 187 | } |