//! constructor CFileSystem::CFileSystem() { #ifdef _DEBUG setDebugName("CFileSystem"); #endif setFileListSystem(FILESYSTEM_NATIVE); //! reset current working directory getWorkingDirectory(); #ifdef __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_ ArchiveLoader.push_back(new CArchiveLoaderZIP(this)); #endif #ifdef __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_ ArchiveLoader.push_back(new CArchiveLoaderMount(this)); #endif #ifdef __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_ ArchiveLoader.push_back(new CArchiveLoaderPAK(this)); #endif #ifdef __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_ ArchiveLoader.push_back(new CArchiveLoaderTAR(this)); #endif }
//! constructor CFileSystem::CFileSystem() { #ifdef _DEBUG setDebugName("CFileSystem"); #endif setFileListSystem(FILESYSTEM_NATIVE); addArchiveLoader(new CArchiveLoaderZIP(this)); addArchiveLoader(new CArchiveLoaderMount(this)); addArchiveLoader(new CArchiveLoaderPAK(this)); }
//! Creates a list of files and directories in the current working directory IFileList* CFileSystem::createFileList() { FileEntry e2; FileEntry e3; if ( FileSystemType == FILESYSTEM_NATIVE ) return new CFileList(); CFileList* r = new CFileList( "virtual" ); r->Path = WorkingDirectory [ FILESYSTEM_VIRTUAL ]; for ( u32 i = 0; i != FileArchives.size(); ++i) { CFileList* flist[2] = { 0, 0 }; //! merge relative folder file archives if ( FileArchives[i]->getArchiveType() == "mount" ) { EFileSystemType currentType = setFileListSystem ( FILESYSTEM_NATIVE ); core::string<c16> save ( getWorkingDirectory () ); core::string<c16> current; current = FileArchives[i]->getArchiveName() + WorkingDirectory [ FILESYSTEM_VIRTUAL ]; flattenFilename ( current ); if ( changeWorkingDirectoryTo ( current ) ) { flist[0] = new CFileList( "mountpoint" ); flist[0]->constructNative (); changeWorkingDirectoryTo ( save ); } setFileListSystem ( currentType ); } else if ( FileArchives[i]->getArchiveType() == "zip" ) { flist[0] = new CFileList( "zip" ); flist[1] = new CFileList( "zip directory" ); // add relative navigation e2.isDirectory = 1; e2.Name = "."; e2.FullName = r->Path + e2.Name; e2.Size = 0; flist[1]->Files.push_back ( e2 ); e2.Name = ".."; e2.FullName = r->Path + e2.Name; flist[1]->Files.push_back ( e2 ); for ( u32 g = 0; g < FileArchives[i]->getFileCount(); ++g) { const SZipFileEntry *e = (SZipFileEntry*) FileArchives[i]->getFileInfo(g); s32 test = isInSameDirectory ( r->Path, e->zipFileName ); if ( test < 0 || test > 1 ) continue; e2.Size = e->header.DataDescriptor.UncompressedSize; e2.isDirectory = e2.Size == 0; // check missing directories if ( !e2.isDirectory && test == 1 ) { e3.Size = 0; e3.isDirectory = 1; e3.FullName = e->path; e3.Name = e->path.subString ( r->Path.size(), e->path.size() - r->Path.size() - 1 ); if ( flist[1]->Files.binary_search ( e3 ) < 0 ) flist[1]->Files.push_back ( e3 ); } else { e2.FullName = e->zipFileName; e2.Name = e->simpleFileName; if ( !e2.isDirectory ) core::deletePathFromFilename ( e2.Name ); flist[0]->Files.push_back ( e2 ); } } } // add file to virtual directory for ( u32 g = 0; g < 2; ++g ) { if ( !flist[g] ) continue; for ( u32 j = 0; j != flist[g]->Files.size(); ++j ) r->Files.push_back ( flist[g]->Files[j] ); flist[g]->drop(); } } r->Files.sort(); return r; }