@@ -198,56 +198,54 @@ void aiContext::reset()
198
198
bool aiContext::load (const char *in_path)
199
199
{
200
200
auto path = NormalizePath (in_path);
201
+ auto wpath = L (in_path);
201
202
202
- DebugLog ( " aiContext::load: '%s'" , path .c_str ());
203
+ DebugLogW ( L " aiContext::load: '%s'" , wpath .c_str ());
203
204
if (path == m_path && m_archive) {
204
205
DebugLog (" Context already loaded for gameObject with id %d" , m_uid);
205
206
return true ;
206
207
}
207
208
208
- DebugLog (" Alembic file path changed from '%s' to '%s'. Reset context." , m_path.c_str (), path.c_str ());
209
-
210
209
reset ();
211
-
212
- if (path.length () == 0 ) {
210
+ if (path.empty ()) {
213
211
return false ;
214
212
}
215
213
216
214
m_path = path;
217
-
218
215
if (!m_archive.valid ()) {
219
- DebugLog (" Archive '%s' not yet opened" , in_path);
220
-
221
216
try {
222
- DebugLog (" Trying to open AbcCoreOgawa::ReadArchive..." );
223
-
224
- // open archive with wstring path and pass it to Abc::IArchive (Abc::IArchive can not use wstring path...)
225
- auto wpath = L (path);
226
- auto ifs = new std::ifstream (wpath.c_str (), std::ios::in | std::ios::binary);
227
- m_streams.push_back (ifs);
217
+ // Abc::IArchive doesn't accept wide string path. so create file stream with wide string path and pass it.
218
+ // (VisualC++'s std::ifstream accepts wide string)
219
+ m_streams.push_back (
220
+ #ifdef WIN32
221
+ new std::ifstream (wpath.c_str (), std::ios::in | std::ios::binary)
222
+ #else
223
+ new std::ifstream (path.c_str (), std::ios::in | std::ios::binary)
224
+ #endif
225
+ );
228
226
229
227
Alembic::AbcCoreOgawa::ReadArchive archive_reader (m_streams);
230
228
m_archive = Abc::IArchive (archive_reader (m_path), Abc::kWrapExisting , Abc::ErrorHandler::kThrowPolicy );
229
+ DebugLog (" Successfully opened Ogawa archive" );
231
230
}
232
231
catch (Alembic::Util::Exception e) {
233
- DebugLog (" Failed (%s)" , e.what ());
234
-
235
- // hdf5 archive can not use external stream
236
- // (that means if path contains wide characters, we can't open it. I couldn't find solution..)
232
+ // HDF5 archive doesn't accept external stream. so close it.
233
+ // (that means if path contains wide characters, it can't be opened. I couldn't find solution..)
237
234
for (auto s : m_streams) { delete s; }
238
235
m_streams.clear ();
239
236
240
237
try {
241
- DebugLog (" Trying to open AbcCoreHDF5::ReadArchive..." );
242
238
m_archive = Abc::IArchive (AbcCoreHDF5::ReadArchive (), path);
239
+ DebugLog (" Successfully opened HDF5 archive" );
243
240
}
244
241
catch (Alembic::Util::Exception e2 ) {
245
- DebugLog (" Failed (%s)" , e2 .what ());
242
+ auto message = L (e2 .what ());
243
+ DebugLogW (L" Failed to open archive: %s" , message.c_str ());
246
244
}
247
245
}
248
246
}
249
247
else {
250
- DebugLog ( " Archive '%s' already opened" , in_path );
248
+ DebugLogW ( L " Archive '%s' already opened" , wpath. c_str () );
251
249
}
252
250
253
251
if (m_archive.valid ()) {
@@ -260,12 +258,9 @@ bool aiContext::load(const char *in_path)
260
258
for (int i = 0 ; i < num_time_samplings; ++i) {
261
259
m_timesamplings.emplace_back (aiCreateTimeSampling (m_archive, i));
262
260
}
263
-
264
- DebugLog (" Succeeded" );
265
261
return true ;
266
262
}
267
263
else {
268
- DebugError (" Invalid archive '%s'" , in_path);
269
264
reset ();
270
265
return false ;
271
266
}
0 commit comments