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

Method open

dds/DCPS/FileSystemStorage.cpp:269–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

267}
268
269int DDS_Dirent::open(const ACE_TCHAR* path)
270{
271 close();
272 ACE_WString wpath =
273#ifdef ACE_HAS_WINCE
274 path;
275#else
276 to_win32_long_path(path);
277#endif
278
279 // taken from ACE_OS::opendir_emulation() and translated to wchar
280
281 wchar_t extra[3] = {0, 0, 0};
282 const wchar_t* filename = wpath.c_str();
283
284 // Check if filename is a directory.
285 DWORD fileAttribute = ::GetFileAttributesW(filename);
286
287 if (fileAttribute == INVALID_FILE_ATTRIBUTES) {
288 ACE_OS::set_errno_to_last_error();
289 return -1;
290 }
291
292 if (!(fileAttribute & FILE_ATTRIBUTE_DIRECTORY)) {
293 errno = ENOTDIR;
294 return -1;
295 }
296
297 size_t const lastchar = ACE_OS::strlen(filename);
298
299 if (lastchar > 0) {
300 if (filename[lastchar-1] != L'*') {
301 if (filename[lastchar-1] != L'/' && filename[lastchar-1] != L'\\')
302 ACE_OS::strcpy(extra, L"\\*");
303
304 else
305 ACE_OS::strcpy(extra, L"*");
306 }
307 }
308
309 ACE_NEW_RETURN(dirp_, DDS_DIR, -1);
310 ACE_NEW_RETURN(dirp_->directory_name_,
311 wchar_t[lastchar + ACE_OS::strlen(extra) + 1],
312 -1);
313 ACE_OS::strcpy(dirp_->directory_name_, filename);
314
315 if (extra[0])
316 ACE_OS::strcat(dirp_->directory_name_, extra);
317
318 dirp_->current_handle_ = INVALID_HANDLE_VALUE;
319 dirp_->started_reading_ = 0;
320 dirp_->dirent_ = 0;
321 return 0;
322}
323
324DDS_DIRENT* DDS_Dirent::read()
325{

Callers 3

writeMethod · 0.45
readMethod · 0.45
DirectoryMethod · 0.45

Calls 2

closeFunction · 0.85
to_win32_long_pathFunction · 0.85

Tested by

no test coverage detected