int FileManager::OpenDir(const char* path) { dirStatus = 1; dirId = sceIoDopen(path); sceIoDread(dirId, &dirent); sceIoDread(dirId, &dirent); return dirId; }
static int get_fontlist(FontList *list, char *path) { SceIoDirent dir; int result = 0, dfd; char fullpath[256]; memset(&dir, 0, sizeof(dir)); dfd = sceIoDopen(path); if(dfd < 0) { return dfd; } while (sceIoDread(dfd, &dir) > 0) { const char *p; p = strrchr(dir.d_name, '.'); if(p == NULL) p = dir.d_name; if(0 == stricmp(p, ".bin") || 0 == stricmp(p, ".pf") || 0 == stricmp(p, ".fnt") || 0 == stricmp(p, ".tlf")) { sprintf(fullpath, "%s/%s", path, dir.d_name); fontlist_add(list, fullpath); } } sceIoDclose(dfd); return result; }
extern u32 utils_del_dir(const char *dir) { u32 count = 0; int dl = sceIoDopen(dir); SceIoDirent sid; if (dl < 0) return count; memset(&sid, 0, sizeof(SceIoDirent)); while (sceIoDread(dl, &sid)) { char compPath[260]; if (sid.d_name[0] == '.') continue; SPRINTF_S(compPath, "%s/%s", dir, sid.d_name); if (FIO_S_ISDIR(sid.d_stat.st_mode)) { if (utils_del_dir(compPath)) { count++; } continue; } if (utils_del_file(compPath)) { count++; } memset(&sid, 0, sizeof(SceIoDirent)); } sceIoDclose(dl); sceIoRmdir(dir); return count; }
char *find_file(char *pattern, char *path) { static struct dirent file; int fd, i, found, len1, len2; memset(&dir, 0, sizeof(dir)); fd = sceIoDopen(path); found = 0; len1 = strlen(pattern); while (!found) { if (sceIoDread(fd, &dir) <= 0) break; len2 = strlen(dir.d_name); for (i = 0; i < len2; i++) { if (strnicmp(&dir.d_name[i], pattern, len1) == 0) { strcpy(file.name, dir.d_name); found = 1; break; } } } sceIoDclose(fd); return found ? file.name : NULL; }
/* Returns number of files successfully read; negative number if error */ int pl_file_get_file_list(pl_file_list *list, const char *path, const char **filter) { SceUID fd = sceIoDopen(path); if (fd < 0) return -1; SceIoDirent dir; memset(&dir, 0, sizeof(dir)); pl_file *file, *last = NULL; list->files = NULL; const char **pext; int loop; int count = 0; while (sceIoDread(fd, &dir) > 0) { if (filter && !(SCE_S_ISDIR(dir.d_stat.st_mode))) { /* Loop through the list of allowed extensions and compare */ for (pext = filter, loop = 1; *pext; pext++) { if (pl_file_is_of_type(dir.d_name, *pext)) { loop = 0; break; } } if (loop) continue; } /* Create a new file entry */ if (!(file = (pl_file*)malloc(sizeof(pl_file)))) { pl_file_destroy_file_list(list); return -1; } file->name = strdup(dir.d_name); file->next = NULL; file->attrs = (SCE_S_ISDIR(dir.d_stat.st_mode)) ? PL_FILE_DIRECTORY : 0; /* Update preceding element */ if (last) last->next = file; else list->files = file; last = file; count++; } sceIoDclose(fd); /* Sort the files by name */ sort_file_list(list, count); return count; }
void RemoveDir(const char* oldPath) { char *fullOldPath; SceIoDirent oneDir; int oDir = sceIoDopen(oldPath); if (oDir < 0){ return; } while (1){ memset(&oneDir, 0, sizeof(SceIoDirent)); if (sceIoDread(oDir, &oneDir) <= 0) break; if (!strcmp(oneDir.d_name, ".") || !strcmp(oneDir.d_name, "..")) continue; if (oldPath[strlen(oldPath)-1] != '/'){ fullOldPath = (char *)calloc(strlen(oldPath)+strlen(oneDir.d_name)+2,sizeof(char)); sprintf(fullOldPath,"%s/%s",oldPath,oneDir.d_name); } else { fullOldPath = (char *)calloc(strlen(oldPath)+strlen(oneDir.d_name)+1,sizeof(char)); sprintf(fullOldPath,"%s%s",oldPath,oneDir.d_name); } if (FIO_S_ISDIR(oneDir.d_stat.st_mode)){ RemoveDir(fullOldPath); } else if(FIO_S_ISREG(oneDir.d_stat.st_mode)){ sceIoRemove(fullOldPath); } free(fullOldPath); } sceIoDclose(oDir); sceIoRmdir(oldPath); }
struct VDirEntry* _vdsceListNext(struct VDir* vd) { struct VDirSce* vdsce = (struct VDirSce*) vd; if (sceIoDread(vdsce->fd, &vdsce->de.ent) <= 0) { return 0; } return &vdsce->de.d; }
int findfirst(const signed char *pathname, struct ffblk *ffblk, int attrib) { signed char *match=strdup(pathname); unsigned int i; if(match[0]=='*') match++; for(i=0;i<strlen(match);i++) { if(match[i]>='a' && match[i]<='z') match[i]^=32; } dirsize=0; printf("Looking for '%s' (%s)\n",match,pathname); int fd = sceIoDopen(path); SceIoDirent entry; while (sceIoDread(fd, &entry) > 0) { if(strcasestr(entry.d_name,match)==0 && wildcard(entry.d_name,match)==0) continue; if(dirsize==0) { dirfname=(signed char **)calloc(sizeof(signed char *),64); } else if((dirsize%64)==0) { dirfname=(signed char **)realloc(dirfname,sizeof(signed char *)*(dirsize+64)); } dirfname[dirsize++]=strdup(entry.d_name); } sceIoDclose(fd); printf("Got %d matches\n",dirsize); if (dirsize>0) { dirpos=1; strcpy(ffblk->ff_name,dirfname[dirsize-1]); return 0; } return 1; }
static int testIoDread(const char *path) { SceIoDirent ent; SceUID uid; int r, trial; printf("sceIoDopen(\"%s\")...", path); uid = sceIoDopen(path); if (uid < 0) { printf("error: 0x%08X\n", uid); return uid; } puts("OK\n"); trial = 0; do { trial++; printf("sceIoDread (trial: %d)...", trial); r = sceIoDread(uid, &ent); if (r < 0) printf("error: 0x%08X\n", r); else puts("OK\n"); } while (r > 0); puts("sceIoDclose..."); r = sceIoDclose(uid); if (r) printf("error: 0x%08X\n", r); else puts("OK\n"); return 0; }
void find_state_file(UINT8 *slot) { int fd, len; char path[MAX_PATH], pattern[16]; memset(&dir, 0, sizeof(dir)); sprintf(path, "%sstate", launchDir); sprintf(pattern, "%s.sv", game_name); len = strlen(pattern); fd = sceIoDopen(path); while (sceIoDread(fd, &dir) > 0) { if (strnicmp(dir.d_name, pattern, len) == 0) { int number = dir.d_name[len] - '0'; if (number >= 0 && number <= 9) slot[number] = 1; } } sceIoDclose(fd); }
void runTest() { int dfd = sceIoDopen("ms0:/tmp/"); if (dfd <= 0) { pspDebugScreenPrintf("sceIoDopen = 0x%08X\n", dfd); return; } SceIoDirent dir; u8 buffer[1044]; while (1) { memset(&dir, 0, sizeof(dir)); memset(buffer, 0, sizeof(buffer)); ((u32 *) buffer)[0] = sizeof(buffer); dir.d_private = buffer; int result = sceIoDread(dfd, &dir); pspDebugScreenPrintf("sceIoDread = 0x%08X\n", result); if (result <= 0) { break; } int i; for (i = 0; i < sizeof(buffer); i++) { if (buffer[i] != 0) { pspDebugScreenPrintf("[%2d] = 0x%02X('%c') ", i, buffer[i], buffer[i]); } } pspDebugScreenPrintf("\n"); } sceIoDclose(dfd); }
void delete_files(const char *dirname, const char *pattern) { int fd, i, len1, len2; char path[MAX_PATH]; memset(&dir, 0, sizeof(dir)); sprintf(path, "%s%s", launchDir, dirname); fd = sceIoDopen(path); len1 = strlen(pattern); while (1) { if (sceIoDread(fd, &dir) <= 0) break; len2 = strlen(dir.d_name); for (i = 0; i < len2; i++) { if (strnicmp(&dir.d_name[i], pattern, len1) == 0) { char path2[MAX_PATH]; sprintf(path2, "%s/%s", path, dir.d_name); sceIoRemove(path2); } } } sceIoDclose(fd); }
void getSubFiles(char* pDir, CStringList& pOut, CString* search) { SceUID dir; if ((dir = sceIoDopen(pDir)) <= 0) return; SceIoDirent ent; SceIoStat statx; while (sceIoDread(dir, &ent) > 0) { CString fullName = CString() << pDir << ent.d_name; sceIoGetstat(fullName.text(), &statx); if (!(statx.st_mode & S_IFDIR)) { if (search != 0) { CString s( *search ); CString m( ent.d_name ); s.replaceAll( "%", "*" ); s << ".txt"; if (m.match( s.text()) == false) continue; } pOut.add( ent.d_name ); } } sceIoDclose(dir); }
int has_directories(const char *base, const char *path) { SceIoDirent dir; char buffer[256]; int ret = 0; SceUID fd; sce_paf_private_snprintf(buffer, 256, "%s/%s", base, path); kprintf("checking %s\n", buffer); fd = sceIoDopen(buffer); if(fd >= 0) { sce_paf_private_memset(&dir, 0, sizeof(SceIoDirent)); while(sceIoDread(fd, &dir) > 0) { if (FIO_S_ISDIR(dir.d_stat.st_mode) && dir.d_name[0] != '.') { ret = 1; break; } } sceIoDclose(fd); } else { ret = -1; } return ret; }
extern u32 copy_dir(const char *src, const char *dest, t_copy_cb cb, t_copy_overwritecb ocb, void *data) { int dl = sceIoDopen(src); u32 result = 0; SceIoDirent sid; if (dl < 0) { if (cb != NULL) cb(src, dest, false, data); return 0; } sceIoMkdir(dest, 0777); memset(&sid, 0, sizeof(SceIoDirent)); while (sceIoDread(dl, &sid)) { char copysrc[260], copydest[260]; if (sid.d_name[0] == '.') continue; SPRINTF_S(copysrc, "%s/%s", src, sid.d_name); SPRINTF_S(copydest, "%s/%s", dest, sid.d_name); if (FIO_S_ISDIR(sid.d_stat.st_mode)) { result += copy_dir(copysrc, copydest, cb, ocb, data); continue; } if (copy_file(copysrc, copydest, cb, ocb, data)) ++result; memset(&sid, 0, sizeof(SceIoDirent)); } sceIoDclose(dl); return result; }
int FileManager::Next() { if (dirId > NULL && dirStatus > 0) { dirStatus = sceIoDread(dirId, &dirent); } return dirStatus; }
int removePath(char *path, uint32_t *value, uint32_t max, void (* SetProgress)(uint32_t value, uint32_t max)) { SceUID dfd = sceIoDopen(path); if (dfd >= 0) { int res = 0; do { SceIoDirent dir; memset(&dir, 0, sizeof(SceIoDirent)); res = sceIoDread(dfd, &dir); if (res > 0) { if (strcmp(dir.d_name, ".") == 0 || strcmp(dir.d_name, "..") == 0) continue; char *new_path = malloc(strlen(path) + strlen(dir.d_name) + 2); snprintf(new_path, MAX_PATH_LENGTH, "%s/%s", path, dir.d_name); if (SCE_S_ISDIR(dir.d_stat.st_mode)) { removePath(new_path, value, max, SetProgress); } else { sceIoRemove(new_path); if (value) (*value)++; if (SetProgress) SetProgress(value ? *value : 0, max); } free(new_path); } } while (res > 0); sceIoDclose(dfd); int ret = sceIoRmdir(path); if (ret < 0) return ret; if (value) (*value)++; if (SetProgress) SetProgress(value ? *value : 0, max); } else { int ret = sceIoRemove(path); if (ret < 0) return ret; if (value) (*value)++; if (SetProgress) SetProgress(value ? *value : 0, max); } return 0; }
int randomCtf( char * theme ) { int dfd = sceIoDopen( "ms0:/PSP/THEME" ); if ( dfd < 0 ) return -1; int th_count = 0; SceIoDirent ent; memset( &ent, 0, sizeof( SceIoDirent ) ); while ( sceIoDread( dfd, &ent ) > 0 ) { if ( !( ent.d_stat.st_attr & FIO_SO_IFDIR ) && ent.d_name[0] != '.' && cmpistr( ent.d_name, "random.ctf" ) && endwithistr( ent.d_name, ".ctf" ) ) { th_count ++; } log( "name %s %d\n", ent.d_name, th_count ); memset( &ent, 0, sizeof( SceIoDirent ) ); } sceIoDclose( dfd ); if ( th_count <= 0 ) return -1; if ( th_count > 1 ) { time_t tm = sceKernelLibcTime( NULL ); th_count = tm % th_count; } else th_count = 0; dfd = sceIoDopen( "ms0:/PSP/THEME" ); memset( &ent, 0, sizeof( SceIoDirent ) ); while ( sceIoDread( dfd, &ent ) > 0 ) { log( "name %s %d\n", ent.d_name, th_count ); if ( !( ent.d_stat.st_attr & FIO_SO_IFDIR ) && ent.d_name[0] != '.' && cmpistr( ent.d_name, "random.ctf" ) && endwithistr( ent.d_name, "ctf" ) ) { if ( th_count == 0 ) { sprintf( theme, "/PSP/THEME/%s", ent.d_name ); break; } else th_count --; } memset( &ent, 0, sizeof( SceIoDirent ) ); } sceIoDclose( dfd ); return 0; }
void openSettingsMenu() { settings_menu.status = SETTINGS_MENU_OPENING; settings_menu.entry_sel = 0; settings_menu.option_sel = 0; // Get current theme if (theme_name) free(theme_name); readConfig("ux0:VitaShell/theme/theme.txt", theme_entries, sizeof(theme_entries) / sizeof(ConfigEntry)); // Get theme index in main tab int theme_index = -1; int i; for (i = 0; i < (sizeof(main_settings) / sizeof(SettingsMenuOption)); i++) { if (main_settings[i].name == VITASHELL_SETTINGS_THEME) { theme_index = i; break; } } // Find all themes if (theme_index >= 0) { SceUID dfd = sceIoDopen("ux0:VitaShell/theme"); if (dfd >= 0) { theme_count = 0; theme = 0; int res = 0; do { SceIoDirent dir; memset(&dir, 0, sizeof(SceIoDirent)); res = sceIoDread(dfd, &dir); if (res > 0) { if (SCE_S_ISDIR(dir.d_stat.st_mode)) { if (theme_name && strcasecmp(dir.d_name, theme_name) == 0) theme = theme_count; strncpy(theme_options[theme_count], dir.d_name, MAX_THEME_LENGTH); theme_count++; } } } while (res > 0 && theme_count < MAX_THEMES); sceIoDclose(dfd); main_settings[theme_index].options = theme_options; main_settings[theme_index].n_options = theme_count; main_settings[theme_index].value = &theme; } } changed = 0; }
bool PSPFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const { DEBUG_ENTER_FUNC(); assert(_isDirectory); //TODO: honor the hidden flag bool ret = true; if (PowerMan.beginCriticalSection() == PowerManager::Blocked) PSP_DEBUG_PRINT_FUNC("Suspended\n"); // Make sure to block in case of suspend PSP_DEBUG_PRINT_FUNC("Current path[%s]\n", _path.c_str()); int dfd = sceIoDopen(_path.c_str()); if (dfd > 0) { SceIoDirent dir; memset(&dir, 0, sizeof(dir)); while (sceIoDread(dfd, &dir) > 0) { // Skip 'invisible files if (dir.d_name[0] == '.') continue; PSPFilesystemNode entry; entry._isValid = true; entry._displayName = dir.d_name; Common::String newPath(_path); if (newPath.lastChar() != '/') newPath += '/'; newPath += dir.d_name; entry._path = newPath; entry._isDirectory = dir.d_stat.st_attr & FIO_SO_IFDIR; PSP_DEBUG_PRINT_FUNC("Child[%s], %s\n", entry._path.c_str(), entry._isDirectory ? "dir" : "file"); // Honor the chosen mode if ((mode == Common::FSNode::kListFilesOnly && entry._isDirectory) || (mode == Common::FSNode::kListDirectoriesOnly && !entry._isDirectory)) continue; myList.push_back(new PSPFilesystemNode(entry)); } sceIoDclose(dfd); ret = true; } else { // dfd <= 0 ret = false; } PowerMan.endCriticalSection(); return ret; }
bool FindFileNext( FindHandleT handle, FindDataT & data ) { DAEDALUS_ASSERT( handle >= 0, "Cannot search with invalid directory handle" ); if( sceIoDread( handle, &gDirEntry.Dirent ) > 0 ) { IO::Path::Assign( data.Name, gDirEntry.Dirent.d_name ); return true; } return false; }
bool MFFileNative_FindFirst(MFFind *pFind, const char *pSearchPattern, MFFindData *pFindData) { SceIoDirent findData; int findStatus; // separate path and search pattern.. char *pPath = (char*)MFStr("%s/%s%s", gPSPSystemPath, (char*)pFind->pMount->pFilesysData, pSearchPattern); const char *pPattern = pPath; char *pLast = MFString_RChr(pPath, '/'); if(pLast) { *pLast = 0; pPattern = pLast + 1; } else { // find pattern refers to current directory.. pPath = "."; } // open the directory SceUID hFind = sceIoDopen(pPath); if(hFind < 0) { MFDebug_Warn(2, MFStr("Couldnt open directory '%s' with search pattern '%s'", pPath, pPattern)); return false; } findStatus = sceIoDread(hFind, &findData); MFDebug_Assert(findStatus >= 0, "Error reading directory."); if(findStatus == 0) return false; pFindData->attributes = (FIO_SO_ISDIR(findData.d_stat.st_attr) ? MFFA_Directory : 0) | (FIO_SO_ISLNK(findData.d_stat.st_attr) ? MFFA_SymLink : 0); pFindData->fileSize = (uint64)findData.d_stat.st_size; MFString_Copy((char*)pFindData->pFilename, findData.d_name); MFString_CopyCat(pFindData->pSystemPath, (char*)pFind->pMount->pFilesysData, pSearchPattern); pLast = MFString_RChr(pFindData->pSystemPath, '/'); if(pLast) pLast[1] = 0; else pFindData->pSystemPath[0] = 0; pFind->pFilesystemData = (void*)hFind; return true; }
int getPathInfo(char *path, uint32_t *size, uint32_t *folders, uint32_t *files) { SceUID dfd = sceIoDopen(path); if (dfd >= 0) { int res = 0; do { SceIoDirent dir; memset(&dir, 0, sizeof(SceIoDirent)); res = sceIoDread(dfd, &dir); if (res > 0) { if (strcmp(dir.d_name, ".") == 0 || strcmp(dir.d_name, "..") == 0) continue; char *new_path = malloc(strlen(path) + strlen(dir.d_name) + 2); snprintf(new_path, MAX_PATH_LENGTH, "%s/%s", path, dir.d_name); if (SCE_S_ISDIR(dir.d_stat.st_mode)) { getPathInfo(new_path, size, folders, files); } else { if (size) (*size) += dir.d_stat.st_size; if (files) (*files)++; } free(new_path); } } while (res > 0); sceIoDclose(dfd); if (folders) (*folders)++; } else { if (size) { SceIoStat stat; memset(&stat, 0, sizeof(SceIoStat)); int res = sceIoGetstat(path, &stat); if (res < 0) return res; (*size) += stat.st_size; } if (files) (*files)++; } return 0; }
DirectoryResult DirectoryNext(Directory directory, DirectoryEntry *entry) { DirectoryResult result = Directory_Error; if (directory == DirectoryInvalid) return Directory_Error; #if defined(_WIN32) DirectoryData *dirData = (DirectoryData*)directory; if (dirData->IsEnd == TRUE) return Directory_EndOfEntries; strncpy(entry->name, dirData->FindData.cFileName, MAX_PATH); entry->length = dirData->FindData.nFileSizeLow; bool isreadonly = (dirData->FindData.dwFileAttributes & FILE_ATTRIBUTE_READONLY) != 0; bool ishidden = (dirData->FindData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0; bool issystem = (dirData->FindData.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) != 0; bool isdirectory = (dirData->FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; if (isdirectory) entry->length = -1; BOOL ret = FindNextFile(dirData->hDir, &dirData->FindData); if (ret == FALSE) { if (GetLastError() != ERROR_NO_MORE_FILES) return Directory_Error; dirData->IsEnd = TRUE; } result = Directory_Continue; #elif defined(PLATFORM_PSP2) SceIoDirent dir; int res = sceIoDread((SceUID)directory, &dir); if (res < 0) return Directory_Error; strcpy(entry->name, dir.d_name); if (PSP2_S_ISDIR(dir.d_stat.st_mode)) entry->length = -1; else entry->length = dir.d_stat.st_size; result = res == 0 ? Directory_EndOfEntries : Directory_Continue; #endif // Check for "." or ".." if (result == Directory_Continue) { if (entry->length < 0 && entry->name[0] == '.') { // Probably it's the directory pointer, do more checks if (entry->name[1] == '\0' || (entry->name[1] == '.' && entry->name[2] == '\0')) // it is, recursively call again DirectoryNext return DirectoryNext(directory, entry); } } return result; }
/* ================ CheckForPak ================ */ bool CheckForMod(char* dir) { int dd = sceIoDopen(dir); SceIoDirent entry; int res; bool ret = false; while ((res = sceIoDread(dd, &entry)) > 0 && (!ret)) if ( strstr(strtolower(entry.d_name),".pak") != NULL || !strcmp(strtolower(entry.d_name), "progs.dat") ) ret = true; // Enable checks for progs.dat only mods sceIoDclose(dd); return ret; }
int main(int argc, char **argv) { int result; int directory; SceIoDirent directoryEntry; directory = sceIoDopen("disc0:/PSP_GAME"); do { result = sceIoDread(directory, &directoryEntry); printf("%d : '%s'\n", result, directoryEntry.d_name); } while(result > 0); return 0; }
int fileListGetDirectoryEntries(FileList *list, char *path) { SceUID dfd = sceIoDopen(path); if (dfd < 0) return dfd; FileListEntry *entry = malloc(sizeof(FileListEntry)); strcpy(entry->name, DIR_UP); entry->is_folder = 1; entry->type = FILE_TYPE_UNKNOWN; fileListAddEntry(list, entry, SORT_BY_NAME_AND_FOLDER); int res = 0; do { SceIoDirent dir; memset(&dir, 0, sizeof(SceIoDirent)); res = sceIoDread(dfd, &dir); if (res > 0) { if (strcmp(dir.d_name, ".") == 0 || strcmp(dir.d_name, "..") == 0) continue; FileListEntry *entry = malloc(sizeof(FileListEntry)); strcpy(entry->name, dir.d_name); entry->is_folder = SCE_S_ISDIR(dir.d_stat.st_mode); if (entry->is_folder) { addEndSlash(entry->name); entry->type = FILE_TYPE_UNKNOWN; } else { /* char file[MAX_PATH_LENGTH]; snprintf(file, MAX_PATH_LENGTH, "%s%s", path, entry->name); entry->type = getFileType(file); */ entry->type = FILE_TYPE_UNKNOWN; } memcpy(&entry->time, (SceRtcTime *)&dir.d_stat.st_mtime, sizeof(SceRtcTime)); entry->size = dir.d_stat.st_size; fileListAddEntry(list, entry, SORT_BY_NAME_AND_FOLDER); } } while (res > 0); sceIoDclose(dfd); return 0; }
int retro_readdir(struct RDIR *rdir) { #if defined(_WIN32) return (FindNextFile(rdir->directory, &rdir->entry) != 0); #elif defined(VITA) || defined(PSP) return (sceIoDread(rdir->directory, &rdir->entry) > 0); #elif defined(__CELLOS_LV2__) uint64_t nread; rdir->error = cellFsReaddir(rdir->directory, &rdir->entry, &nread); return (nread != 0); #else return ((rdir->entry = readdir(rdir->directory)) != NULL); #endif }
static void addmedialistpath(char *path) { int dirid; int retval; int x; int found; SceIoDirent *direntt; if ((dirid = sceIoDopen(path)) > 0) { // Opened ok retval = 1; //direntt = (SceIoDirent *)malloc(sizeof(SceIoDirent)); direntt = (SceIoDirent *) & direnta; while ((retval > 0) && (files_infonum < MAX_FILE_NUM)) { retval = sceIoDread(dirid, direntt); if (retval > 0) { sceKernelDcacheWritebackAll(); if ((direntt->d_stat.st_attr & 0x10) == 0x10) { // directory if (direntt->d_name[0] != '.') { char *pathname = (char *) malloc(200); sprintf(pathname, "%s%s/", path, direntt->d_name); addmedialistpath(pathname); //free(pathname); // dont free, as used in files } } // else if (((direntt->d_stat.st_attr & 0x20) == 0x20) && (direntt->d_name[0] != 0)) { // File else if (direntt->d_name[0] != 0) { // File // Only add files of types known to codecs loaded // Now check against the codecs known to us found = 0; for (x = 0; x < codecnum; x++) { char *ptr = stubs[x].extension; while (*ptr != 0) { if (strncasecmp(&direntt->d_name[strlen(direntt->d_name) - 3], ptr, 3) == 0) found = 1; ptr += 4; } } if (found == 1) { files_info[files_infonum].filename = (char *) malloc(200); memcpy(files_info[files_infonum].filename, direntt->d_name, 200); files_info[files_infonum].pathname = path; files_infonum++; } // if found } // if d_name } // if retval //free(direntt); } // while sceIoDclose(dirid); } // if }
void IndexCategories(Category *head[], const char *path, int location) { SceIoDirent dir; SceUID fd; u64 mtime; char full_path[16]; int match; sce_paf_private_strcpy(full_path, path); SET_DEVICENAME(full_path, location); if((fd = sceIoDopen(full_path)) < 0) { return; } kprintf("Indexing categories from %s, loc: %i\n", path, location); match = 0; sce_paf_private_memset(&dir, 0, sizeof(SceIoDirent)); while(1) { if(sceIoDread(fd, &dir) <= 0) { kprintf("End of directory list\n"); sceIoDclose(fd); break; } kprintf("checking [%s], length: %i\n", dir.d_name, sce_paf_private_strlen(dir.d_name)); if (FIO_S_ISDIR(dir.d_stat.st_mode) && dir.d_name[0] != '.') { if(!config.prefix && !is_game_folder(full_path, dir.d_name)) { if(has_directories(full_path, dir.d_name) > 0) { match = 1; } } else if(config.prefix && sce_paf_private_strncmp(dir.d_name, "CAT_", 4) == 0) { if(has_directories(full_path, dir.d_name) > 0) { sce_paf_private_strcpy(dir.d_name, dir.d_name + 4); match = 1; } } if(match) { match = 0; sceRtcGetTick((pspTime *) &dir.d_stat.st_mtime, &mtime); kprintf("Adding category: [%s]\n", dir.d_name); AddCategory(head, dir.d_name, mtime, location); } } } }