예제 #1
0
 public LzStream(string path, bool useCreateFile = true)
 {
     _handle = useCreateFile
         ? Compression.LzCreateFile(path, out string uncompressedName)
         : Compression.LzOpenFile(path, out uncompressedName);
     UncompressedName = uncompressedName;
 }
예제 #2
0
        public static unsafe int LzRead(LzHandle handle, byte *buffer, int offset, int count)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(offset));
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(count));
            }

            return(ValidateLzResult(Imports.LZRead(handle, buffer + offset, count)));
        }
예제 #3
0
        public static LzHandle LzCreateFile(
            string path,
            out string uncompressedName,
            DesiredAccess access         = DesiredAccess.GenericRead,
            ShareModes share             = ShareModes.ReadWrite,
            CreationDisposition creation = CreationDisposition.OpenExisting)
        {
            string   name   = null;
            LzHandle handle = null;

            BufferHelper.BufferInvoke((StringBuffer buffer) =>
            {
                buffer.EnsureCharCapacity(Paths.MaxPath);
                int result = ValidateLzResult(Imports.LZCreateFileW(path, access, share, creation, buffer), path);

                buffer.SetLengthToFirstNull();
                name   = buffer.ToString();
                handle = new LzCreateHandle(result);
            });

            uncompressedName = name;
            return(handle);
        }
예제 #4
0
        public static unsafe int LzRead(LzHandle handle, byte[] buffer, int offset, int count)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(offset));
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(count));
            }
            if (offset + count > buffer.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(count));

                fixed(byte *b = &buffer[offset])
                {
                    return(ValidateLzResult(Imports.LZRead(handle, b, count)));
                }
        }
예제 #5
0
 public static int LzSeek(LzHandle handle, int offset, MoveMethod origin)
 {
     return(ValidateLzResult(Imports.LZSeek(handle, offset, origin)));
 }