U0 ViewComics() { I64 i=0; U8 *st; CDirEntry *tempm,*tempm1; CDoc *doc=DocNew; DocPutS(doc,"$$FG,LTBLUE$$"); tempm=FilesFind("Comics/*.TXT*"); tempm1=tempm; while (tempm1) { st=StrNew(tempm1->name); FileExtRem(st); tempm1->user_data=DocPrintF(doc,"$$MU-UL,\"%-10ts\",%d$$ ",st,tempm1); Free(st); tempm1=tempm1->next; if ((i++&3)==3) DocPutS(doc,"\n"); } while (TRUE) { if ((tempm1=PopUpMenu(doc))>0) Ed(tempm1->full_name); else break; } DocDel(doc); CDirLstDel(tempm); }
U0 Main() { I64 i,cnt=0; CDirEntry *tempm=FilesFind("::/TempleOS/*",FUF_RECURSE), **a=FilesOrder(tempm,&cnt); for (i=0;i<cnt;i++) { "%08X %s\n",a[i]->cluster,a[i]->full_name; CDirEntryDel(a[i]); } Free(a); }
U0 WebLogScramble(U8 *wild) { CDirEntry *tempm=FilesFind(wild,FUF_RECURSE|FUF_JUST_FILES), *tempm1; InitKey; while (tempm) { tempm1=tempm->next; LogScrambleFile(tempm->full_name); CDirEntryDel(tempm); tempm=tempm1; } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Searches for files according to specified Mask starting from specified Path. Links all found into the FileListHead. // Returns number of files found. // ULONG FilesFind( PWCHAR Directory, // directory name to search in PWCHAR Mask, // search mask ULONG Flags, // variouse flags PLIST_ENTRY FileListHead // result list of file descriptors ) { ULONG bSize, Found = 0; HANDLE hDir; NTSTATUS ntStatus; UNICODE_STRING uDirectory; OBJECT_ATTRIBUTES oa = {0}; IO_STATUS_BLOCK IoStatus = {0}; PFILE_DIRECTORY_INFORMATION FileInfo, CurInfo; PFILE_DIRECTORY_ENTRY DirEntry; ULONG DirLenBytes = wcslen(Directory) * sizeof(WCHAR); RtlInitUnicodeString(&uDirectory, Directory); InitializeObjectAttributes(&oa, &uDirectory, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, 0, NULL); ntStatus = ZwCreateFile(&hDir, GENERIC_READ, &oa, &IoStatus, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_OPEN, FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0); if (NT_SUCCESS(ntStatus)) { if (FileInfo = MyAllocatePool(PagedPool, PAGE_SIZE)) { do { ntStatus = ZwQueryDirectoryFile(hDir, NULL, NULL, 0, &IoStatus, FileInfo, PAGE_SIZE - sizeof(WCHAR), FileDirectoryInformation, FALSE, NULL, FALSE); if (NT_SUCCESS(ntStatus)) { CurInfo = FileInfo; do { if (CurInfo->FileName[0] != '.') { if (!(CurInfo->FileAttributes & FILE_ATTRIBUTE_DIRECTORY) || (Flags & FILES_FIND_DIRECTORIES)) { ULONG NameLen = CurInfo->FileNameLength >> 1; WCHAR z = CurInfo->FileName[NameLen]; CurInfo->FileName[NameLen] = 0; if (__wcswicmp(Mask, (PWCHAR)&CurInfo->FileName)) { if (DirEntry = FilesAlocateDirEntry(DirLenBytes + CurInfo->FileNameLength)) { RtlCopyMemory(&DirEntry->FileInfo, CurInfo, sizeof(FILE_DIRECTORY_INFORMATION)); RtlCopyMemory(&DirEntry->FileInfo.FileName, Directory, DirLenBytes); RtlCopyMemory(&DirEntry->FileInfo.FileName[DirLenBytes >> 1], &CurInfo->FileName, CurInfo->FileNameLength); InsertTailList(FileListHead, &DirEntry->Entry); Found += 1; } } // if (__wcswicmp(Mask, (PWCHAR)&CurInfo->FileName)) CurInfo->FileName[NameLen] = z; } // if (!(CurInfo->FileAttributes & FILE_ATTRIBUTE_DIRECTORY) || (Flags & FILES_FIND_DIRECTORIES)) if ((CurInfo->FileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (Flags & FILES_SCAN_SUBDIRECTORIES)) { PWCHAR NewDir = MyAllocatePool(PagedPool, DirLenBytes + CurInfo->FileNameLength + 2*sizeof(WCHAR)); if (NewDir) { RtlCopyMemory(NewDir, Directory, DirLenBytes); RtlCopyMemory((PCHAR)NewDir + DirLenBytes, CurInfo->FileName, CurInfo->FileNameLength); NewDir[(DirLenBytes + CurInfo->FileNameLength) >> 1] = '\\'; NewDir[(DirLenBytes + CurInfo->FileNameLength + sizeof(WCHAR)) >> 1] = 0; Found += FilesFind(NewDir, Mask, Flags, FileListHead); MyFreePool(NewDir); } } // if ((CurInfo->FileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (Flags & FILES_SCAN_SUBDIRECTORIES)) } // if (CurInfo->FileName[0] != '.') if (CurInfo->NextEntryOffset == 0) break; CurInfo = (PFILE_DIRECTORY_INFORMATION)((PCHAR)CurInfo + CurInfo->NextEntryOffset); } while(TRUE); } // if (NT_SUCCESS(ntStatus)) } while(NT_SUCCESS(ntStatus));