summaryrefslogtreecommitdiff
path: root/uisimulator/common/filesystem-sim.c
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator/common/filesystem-sim.c')
-rw-r--r--uisimulator/common/filesystem-sim.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/uisimulator/common/filesystem-sim.c b/uisimulator/common/filesystem-sim.c
index f4f6321b7d..54e703ff40 100644
--- a/uisimulator/common/filesystem-sim.c
+++ b/uisimulator/common/filesystem-sim.c
@@ -704,6 +704,41 @@ struct sim_dirent * sim_readdir(DIR *dirp)
704 return entry; 704 return entry;
705} 705}
706 706
707/* read a directory (reentrant) */
708int sim_readdir_r(DIR *dirp, struct sim_dirent *entry, struct sim_dirent **result)
709{
710 if (!result)
711 FILE_ERROR_RETURN(EFAULT, -2);
712
713 *result = NULL;
714
715 if (!entry)
716 FILE_ERROR_RETURN(EFAULT, -3);
717
718 struct dirstr_desc *dirstr = get_dirstr(dirp);
719 if (!dirstr)
720 FILE_ERROR_RETURN(ERRNO, -1);
721
722 entry->info.osdirent = NULL;
723
724 if (readdir_volume(dirstr, entry))
725 {
726 *result = entry;
727 return 0;
728 }
729 OS_DIRENT_T *osdirent = os_readdir(dirstr->osdirp);
730 if (!osdirent)
731 FILE_ERROR_RETURN(ERRNO, -4);
732
733 size_t size = sizeof (entry->d_name);
734 if (strlcpy_from_os(entry->d_name, osdirent->d_name, size) >= size)
735 FILE_ERROR_RETURN(ENAMETOOLONG, -5);
736
737 entry->info.osdirent = osdirent;
738 *result = entry;
739 return 0;
740}
741
707int sim_mkdir(const char *path) 742int sim_mkdir(const char *path)
708{ 743{
709 char ospath[SIM_TMPBUF_MAX_PATH]; 744 char ospath[SIM_TMPBUF_MAX_PATH];