Exemplo n.º 1
0
 public LzStream(string path, bool useCreateFile = true)
 {
     _handle = useCreateFile
         ? Compression.LzCreateFile(path, out string uncompressedName)
         : Compression.LzOpenFile(path, out uncompressedName);
     UncompressedName = uncompressedName;
 }
Exemplo n.º 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)));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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)));
                }
        }
Exemplo n.º 5
0
 public static int LzSeek(LzHandle handle, int offset, MoveMethod origin)
 {
     return(ValidateLzResult(Imports.LZSeek(handle, offset, origin)));
 }