コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
#pragma warning disable IDE0060 // Remove unused parameter
        private MpqArchive(string filePath, MpqArchiveVersion version, MpqFileStreamAttributes listfileAttributes, MpqFileStreamAttributes attributesFileAttributes, int maxFileCount) : this()
#pragma warning restore IDE0060 // Remove unused parameter
        {
            if (maxFileCount < 0)
            {
                throw new ArgumentException(null, nameof(maxFileCount));
            }

            var flags = SFileOpenArchiveFlags.TypeIsFile | SFileOpenArchiveFlags.AccessReadWriteShare;

            flags |= (SFileOpenArchiveFlags)version;

            if (!NativeMethods.SFileCreateArchive(filePath, (uint)flags, int.MaxValue, out _handle))
            {
                throw new Win32Exception();
            }
        }
コード例 #4
0
ファイル: MpqArchive.cs プロジェクト: robpaveza/stormlibsharp
 public static MpqArchive CreateNew(string mpqPath, MpqArchiveVersion version, MpqFileStreamAttributes listfileAttributes,
     MpqFileStreamAttributes attributesFileAttributes, int maxFileCount)
 {
     return new MpqArchive(mpqPath, version, listfileAttributes, attributesFileAttributes, maxFileCount);
 }
コード例 #5
0
ファイル: MpqArchive.cs プロジェクト: robpaveza/stormlibsharp
        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();
        }
コード例 #6
0
 public static MpqArchive CreateNew(string mpqPath, MpqArchiveVersion version, MpqFileStreamAttributes listfileAttributes,
                                    MpqFileStreamAttributes attributesFileAttributes, int maxFileCount)
 {
     return(new MpqArchive(mpqPath, version, listfileAttributes, attributesFileAttributes, maxFileCount));
 }