#ifndef IZIPFILECONTENTPROVIDER_H__ #define IZIPFILECONTENTPROVIDER_H__ #include "../IContentProvider.h" #include "../../LString.h" #include "../IFileSystem.h" //#include "test.h" #include "../../minizip/unzip.h" #include "IZipFolder.h" namespace LifeCore { class IZipFileContentProvider : public IContentProvider { public: ~IZipFileContentProvider(){}; void Close(){} IFileSystem* getFileSystem(){return g_fs;} IZipFileContentProvider(const String& zipFile); String g_rootFolder; protected: unz_global_info globalInfo; IFileSystem* g_fs; void BuildTree(); String GetZipPathWithoutFilename(const String& path); public: unzFile g_sourceFile; /*private: private string GetFilename(string path) { return System.IO.Path.GetFileName("C:\\" + path); } private IZipFolder BuildDirectory(string path) { string[] parts = path.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries); IZipFolder folder = (IZipFolder)g_fs.GetRootFolder(); string npath = ""; for (int i = 0; i < parts.Length; i++) { npath+=parts[i] + "/"; IZipFolder f= (IZipFolder)folder.GetFolder(parts[i]); if (f != null) { folder = f; } else { f = new IZipFolder(); f.EntryName = npath; f.Name = parts[i]; f.Provider = this; folder.AddFolder(f); folder = f; } } return folder; } private int ScanFolder(IFolder f) { string P = f.Path; string[] dirs = System.IO.Directory.GetDirectories(g_rootFolder + P); for (int i = 0; i < dirs.Length; i++) { } string[] files = System.IO.Directory.GetFiles(g_rootFolder + P); for (int i = 0; i < files.Length; i++) { IFSFile desc = new IFSFile(); desc.FileName = System.IO.Path.GetFileName(files[i]); desc.Provider = this; FileInfo info = new FileInfo(files[i]); desc.Size = (int)info.Length; desc.FSPath = files[i]; f.AddFile(desc); } return dirs.Length; } private string GetDirFromPath(string path) { string[] dirs = path.Split(System.IO.Path.DirectorySeparatorChar); return dirs[dirs.Length - 1]; } public: ZipFile GetSource() { return g_sourceFile; } IFolder CreateFolder(string path) { return null; } IFileDescriptor CreateFile(string path) { System.IO.File.Create(path).Close(); IFSFile file = new IFSFile(); file.FileName = System.IO.Path.GetFileName(path); file.FSPath = path; file.Provider = this; return file; } override void Close() { if (g_dataStream != null) g_dataStream.Close(); } override LifeEngine.FileSystem.IFileSystem FileSystem { get { return g_fs; } }*/ }; } #endif