MCPcopy Create free account
hub / github.com/F-Stack/f-stack / readdir

Function readdir

dpdk/lib/eal/windows/include/dirent.h:446–523  ·  view source on GitHub ↗

* Read next directory entry. * * When working with text consoles, please note that file names * returned by readdir() are represented in the default ANSI code * page while any output toconsole is typically formatted on another * code page. Thus, non-ASCII characters in file names will not usually * display correctly on console. The problem can be fixed in two ways: * (1) change the characte

Source from the content-addressed store, hash-verified

444 * console code page so many non-ASCII characters will display correctly.
445 */
446static struct dirent*
447readdir(DIR *dirp)
448{
449 WIN32_FIND_DATAW *datap;
450 struct dirent *entp;
451
452 /* Read next directory entry */
453 datap = dirent_next(dirp->wdirp);
454 if (datap) {
455 size_t n;
456 int error;
457
458 /* Attempt to convert file name to multi-byte string */
459 error = dirent_wcstombs_s(&n, dirp->ent.d_name,
460 PATH_MAX, datap->cFileName, PATH_MAX);
461
462 /*
463 * If the file name cannot be represented by a multi-byte
464 * string, then attempt to use old 8+3 file name.
465 * This allows traditional Unix-code to access some file
466 * names despite of unicode characters, although file names
467 * may seem unfamiliar to the user.
468 *
469 * Be ware that the code below cannot come up with a short
470 * file name unless the file system provides one. At least
471 * VirtualBox shared folders fail to do this.
472 */
473 if (error && datap->cAlternateFileName[0] != '\0') {
474 error = dirent_wcstombs_s(
475 &n, dirp->ent.d_name, PATH_MAX,
476 datap->cAlternateFileName, PATH_MAX);
477 }
478
479 if (!error) {
480 DWORD attr;
481
482 /* Initialize directory entry for return */
483 entp = &dirp->ent;
484
485 /* Length of file name excluding zero terminator */
486 entp->d_namlen = n - 1;
487
488 /* File attributes */
489 attr = datap->dwFileAttributes;
490 if ((attr & FILE_ATTRIBUTE_DEVICE) != 0)
491 entp->d_type = DT_CHR;
492 else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0)
493 entp->d_type = DT_DIR;
494 else
495 entp->d_type = DT_REG;
496
497 /* Reset dummy fields */
498 entp->d_ino = 0;
499 entp->d_reclen = sizeof(struct dirent);
500
501 } else {
502 /*
503 * Cannot convert file name to multi-byte string so

Callers 15

smb_retrieve_sharesFunction · 0.85
dm_get_underlying_pathFunction · 0.85
zpool_do_createFunction · 0.85
print_zpool_dir_scriptsFunction · 0.85
zfs_project_handle_dirFunction · 0.85
zed_conf_scan_dirFunction · 0.85
mainFunction · 0.85
UTIL_prepareFileListFunction · 0.85
eal_plugindir_initFunction · 0.85

Calls 2

dirent_nextFunction · 0.85
dirent_wcstombs_sFunction · 0.85

Tested by 4

mainFunction · 0.68
process_hugefilesFunction · 0.68
get_number_of_socketsFunction · 0.68
process_dupFunction · 0.68