public MpqArchive(string filePath, FileAccess accessType) { FilePath = filePath; _openFiles = new ConcurentSet <MpqFileStream>(); _compactCallbacks = new List <MpqArchiveCompactingEventHandler>(); _accessType = accessType; SFileOpenArchiveFlags flags = SFileOpenArchiveFlags.TypeIsFile; if (accessType == FileAccess.Read) { flags |= SFileOpenArchiveFlags.AccessReadOnly; } else { flags |= SFileOpenArchiveFlags.AccessReadWriteShare; } // constant 2 = SFILE_OPEN_HARD_DISK_FILE if (!NativeMethods.SFileOpenArchive(filePath, 2, flags, out _handle)) { throw new Win32Exception(); // Implicitly calls GetLastError } }
private MpqArchive(string filePath, MpqArchiveVersion version, MpqFileStreamAttributes listfileAttributes, MpqFileStreamAttributes attributesFileAttributes, int maxFileCount) { if (maxFileCount < 0) { throw new ArgumentException("maxFileCount"); } SFileOpenArchiveFlags flags = SFileOpenArchiveFlags.TypeIsFile | SFileOpenArchiveFlags.AccessReadWriteShare; flags |= (SFileOpenArchiveFlags)version; //SFILE_CREATE_MPQ create = new SFILE_CREATE_MPQ() //{ // cbSize = unchecked((uint)Marshal.SizeOf(typeof(SFILE_CREATE_MPQ))), // dwMaxFileCount = unchecked((uint)maxFileCount), // dwMpqVersion = (uint)version, // dwFileFlags1 = (uint)listfileAttributes, // dwFileFlags2 = (uint)attributesFileAttributes, // dwStreamFlags = (uint)flags, //}; //if (!NativeMethods.SFileCreateArchive2(filePath, ref create, out _handle)) // throw new Win32Exception(); if (!NativeMethods.SFileCreateArchive(filePath, (uint)flags, int.MaxValue, out _handle)) { throw new Win32Exception(); } }
public MpqArchive(MemoryMappedFile file, FileAccess accessType) { _accessType = accessType; string fileName = Win32Methods.GetFileNameOfMemoryMappedFile(file); if (fileName == null) { throw new ArgumentException("Could not retrieve the name of the file to initialize."); } SFileOpenArchiveFlags flags = SFileOpenArchiveFlags.TypeIsMemoryMapped; if (accessType == FileAccess.Read) { flags |= SFileOpenArchiveFlags.AccessReadOnly; } else { flags |= SFileOpenArchiveFlags.AccessReadWriteShare; } // constant 2 = SFILE_OPEN_HARD_DISK_FILE if (!NativeMethods.SFileOpenArchive(fileName, 2, flags, out _handle)) { throw new Win32Exception(); // Implicitly calls GetLastError } }
private MpqArchive(string filePath, MpqArchiveVersion version, MpqFileStreamAttributes listfileAttributes, MpqFileStreamAttributes attributesFileAttributes, int maxFileCount) { if (maxFileCount < 0) { throw new ArgumentException("maxFileCount"); } SFileOpenArchiveFlags flags = SFileOpenArchiveFlags.TypeIsFile | SFileOpenArchiveFlags.AccessReadWriteShare; flags |= (SFileOpenArchiveFlags)version; if (!NativeMethods.SFileCreateArchive(filePath, (uint)flags, int.MaxValue, out _handle)) { throw new Win32Exception(); } }
public MpqArchive(string filePath, FileAccess accessType) { _accessType = accessType; SFileOpenArchiveFlags flags = SFileOpenArchiveFlags.TypeIsFile; if (accessType == FileAccess.Read) { flags |= SFileOpenArchiveFlags.AccessReadOnly; } else { flags |= SFileOpenArchiveFlags.AccessReadWriteShare; } // constant 2 = SFILE_OPEN_HARD_DISK_FILE if (!NativeMethods.SFileOpenArchive(filePath, 2, flags, out _handle)) { throw new Win32Exception(); // Implicitly calls GetLastError } }
public static extern bool SFileOpenArchive( [MarshalAs(UnmanagedType.LPTStr)] string szMpqName, uint dwPriority, SFileOpenArchiveFlags dwFlags, out MpqArchiveSafeHandle phMpq );