// --------------------------------------------------------------------------------------------- // Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved. // See LICENSE file in the project root for license information. // --------------------------------------------------------------------------------------------- namespace Pal3.Core.FileSystem { using System.Collections.Generic; /// /// File system wrapper for CPack archives /// public interface ICpkFileSystem { /// /// Get file system's root path. /// /// Root directory path public string GetRootPath(); /// /// Mount a Cpk archive to the file system. /// /// CPK file relative path /// Codepage CPK file uses for encoding text info public void Mount(string cpkFileRelativePath, int codepage); /// /// Check if file exists in the archive or any of the segmented archives using virtual path. /// /// File virtual path {Cpk file name}\{File relative path inside archive} /// Example: music.cpk\music\PI01.mp3 /// True if file exists public bool FileExists(string fileVirtualPath); /// /// Check if file exists in the archive or any of the segmented archives using virtual path. /// /// File virtual path {Cpk file name}\{File relative path inside archive} /// Example: music.cpk\music\PI01.mp3 /// Name of the archive or the segmented archive if exists /// True if file exists public bool FileExists(string fileVirtualPath, out string archiveName); /// /// Read all bytes of the given file. /// /// File virtual path inside CPK archive /// Decompressed, ready-to-go file content in byte array public byte[] ReadAllBytes(string fileVirtualPath); /// /// Preload archive into memory for faster read performance. /// public void LoadArchiveIntoMemory(string cpkFileName); /// /// Dispose in-memory archive data. /// public void DisposeInMemoryArchive(string cpkFileName); /// /// Dispose all in-memory archive data. /// public void DisposeAllInMemoryArchives(); /// /// Extract all archives to the specified destination /// public void ExtractTo(string outputFolder); /// /// Searches for files in the file system that match the specified keyword. /// /// The keyword to search for. If empty, all files will be returned. /// A list of file paths that match the specified keyword. public IList Search(string keyword = ""); /// /// Searches for files in the CPK file system that match the specified keywords. /// /// The list of keywords to search for. /// A dictionary where the keys are the file paths of the matching files, /// and the values are the lines in the files that contain the keywords. public IDictionary> BatchSearch(IList keywords); } }