MCPcopy Create free account
hub / github.com/audacity/audacity / opendir

Function opendir

lib-src/sqlite/shell.c:1247–1290  ·  view source on GitHub ↗

** Implementation of the POSIX opendir() function using the MSVCRT. */

Source from the content-addressed store, hash-verified

1245** Implementation of the POSIX opendir() function using the MSVCRT.
1246*/
1247LPDIR opendir(
1248 const char *dirname
1249){
1250 struct _finddata_t data;
1251 LPDIR dirp = (LPDIR)sqlite3_malloc(sizeof(DIR));
1252 SIZE_T namesize = sizeof(data.name) / sizeof(data.name[0]);
1253
1254 if( dirp==NULL ) return NULL;
1255 memset(dirp, 0, sizeof(DIR));
1256
1257 /* TODO: Remove this if Unix-style root paths are not used. */
1258 if( sqlite3_stricmp(dirname, "/")==0 ){
1259 dirname = windirent_getenv("SystemDrive");
1260 }
1261
1262 memset(&data, 0, sizeof(struct _finddata_t));
1263 _snprintf(data.name, namesize, "%s\\*", dirname);
1264 dirp->d_handle = _findfirst(data.name, &data);
1265
1266 if( dirp->d_handle==BAD_INTPTR_T ){
1267 closedir(dirp);
1268 return NULL;
1269 }
1270
1271 /* TODO: Remove this block to allow hidden and/or system files. */
1272 if( is_filtered(data) ){
1273next:
1274
1275 memset(&data, 0, sizeof(struct _finddata_t));
1276 if( _findnext(dirp->d_handle, &data)==-1 ){
1277 closedir(dirp);
1278 return NULL;
1279 }
1280
1281 /* TODO: Remove this block to allow hidden and/or system files. */
1282 if( is_filtered(data) ) goto next;
1283 }
1284
1285 dirp->d_first.d_attributes = data.attrib;
1286 strncpy(dirp->d_first.d_name, data.name, NAME_MAX);
1287 dirp->d_first.d_name[NAME_MAX] = '\0';
1288
1289 return dirp;
1290}
1291
1292/*
1293** Implementation of the POSIX readdir() function using the MSVCRT.

Callers 6

lilv_dir_for_eachFunction · 0.85
osdir_list_startFunction · 0.85
osdir_list_startFunction · 0.85
osdir_list_startFunction · 0.85
listFilesMethod · 0.85
fsdirNextFunction · 0.85

Calls 2

windirent_getenvFunction · 0.85
closedirFunction · 0.85

Tested by

no test coverage detected