MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / read

Method read

dds/DCPS/FileSystemStorage.cpp:324–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322}
323
324DDS_DIRENT* DDS_Dirent::read()
325{
326 if (!dirp_) return 0;
327
328 // taken from ACE_OS::readdir_emulation() and translated to wchar
329 // note that the file name inside ACE_DIRENT is still in ACE_TCHARs as long
330 // as ACE_HAS_TCHAR_DIRENT is defined (true for MSVC, false for GCC/MinGW)
331
332 if (dirp_->dirent_ != 0) {
333#ifdef ACE_HAS_TCHAR_DIRENT
334 ACE_OS::free(dirp_->dirent_->d_name);
335#endif
336 ACE_OS::free(dirp_->dirent_);
337 dirp_->dirent_ = 0;
338 }
339
340 if (!dirp_->started_reading_) {
341 dirp_->current_handle_ = ::FindFirstFileW(dirp_->directory_name_,
342 &dirp_->fdata_);
343 dirp_->started_reading_ = 1;
344
345 } else {
346 int retval = ::FindNextFileW(dirp_->current_handle_, &dirp_->fdata_);
347
348 if (retval == 0) {
349 // Make sure to close the handle explicitly to avoid a leak!
350 ::FindClose(dirp_->current_handle_);
351 dirp_->current_handle_ = INVALID_HANDLE_VALUE;
352 }
353 }
354
355 if (dirp_->current_handle_ != INVALID_HANDLE_VALUE) {
356 dirp_->dirent_ = (DDS_DIRENT*) ACE_Allocator::instance()->malloc(sizeof(DDS_DIRENT));
357
358 if (dirp_->dirent_ != 0) {
359#ifdef ACE_HAS_TCHAR_DIRENT
360 dirp_->dirent_->d_name =
361 (ACE_TCHAR*) ACE_Allocator::instance()->malloc((ACE_OS::strlen(dirp_->fdata_.cFileName)
362 + 1) * sizeof(ACE_TCHAR));
363 ACE_OS::strcpy(dirp_->dirent_->d_name,
364 ACE_TEXT_WCHAR_TO_TCHAR(dirp_->fdata_.cFileName));
365#else // MinGW: d_name is a fixed-size char array
366 ACE_OS::strncpy(dirp_->dirent_->d_name,
367 ACE_Wide_To_Ascii(dirp_->fdata_.cFileName).char_rep(),
368 sizeof(dirp_->dirent_->d_name));
369#endif
370 dirp_->dirent_->d_reclen = sizeof(DDS_DIRENT);
371 }
372
373 return dirp_->dirent_;
374
375 } else
376 return 0;
377}
378
379void DDS_Dirent::close()
380{

Callers 15

readFunction · 0.45
readFunction · 0.45
readFunction · 0.45
readFunction · 0.45
readFunction · 0.45
readFunction · 0.45
read_fileFunction · 0.45
on_data_availableMethod · 0.45
recursive_removeFunction · 0.45
scan_dirMethod · 0.45
initMethod · 0.45
on_data_availableMethod · 0.45

Calls 4

freeFunction · 0.85
instanceFunction · 0.85
mallocMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected