コード例 #1
0
        public static void ArcMoveUseVectorMode(AxisID axis1, AxisID axis2, PointF tartgetPointF, PointF centroPointF,
                                                ArcDirectory arcDirectory)
        {
            var aixsGroup = new ushort[2];

            aixsGroup[0] = (ushort)axis1;
            aixsGroup[1] = (ushort)axis2;

            var targetPoint = new long[2];

            targetPoint[0] = (long)tartgetPointF.X;
            targetPoint[1] = (long)tartgetPointF.Y;
        }
コード例 #2
0
ファイル: ArcWILL.cs プロジェクト: tenyuhuang/GARbro
        public override void Create(Stream output, IEnumerable <Entry> list, ResourceOptions options,
                                    EntryCallback callback)
        {
            var arc_options = GetOptions <ArcOptions> (options);
            var encoding    = Encodings.cp932.WithFatalFallback();

            int file_count = 0;
            var file_table = new SortedDictionary <string, ArcDirectory>();

            foreach (var entry in list)
            {
                string ext = Path.GetExtension(entry.Name).TrimStart('.').ToUpperInvariant();
                if (string.IsNullOrEmpty(ext))
                {
                    throw new InvalidFileName(entry.Name, arcStrings.MsgNoExtension);
                }
                if (ext.Length > 3)
                {
                    throw new InvalidFileName(entry.Name, arcStrings.MsgExtensionTooLong);
                }
                string name     = Path.GetFileNameWithoutExtension(entry.Name).ToUpperInvariant();
                byte[] raw_name = encoding.GetBytes(name);
                if (raw_name.Length > arc_options.NameLength)
                {
                    throw new InvalidFileName(entry.Name, arcStrings.MsgFileNameTooLong);
                }

                ArcDirectory dir;
                if (!file_table.TryGetValue(ext, out dir))
                {
                    byte[] raw_ext = encoding.GetBytes(ext);
                    if (raw_ext.Length > 3)
                    {
                        throw new InvalidFileName(entry.Name, arcStrings.MsgExtensionTooLong);
                    }
                    dir = new ArcDirectory {
                        Extension = raw_ext, Files = new List <ArcEntry>()
                    };
                    file_table[ext] = dir;
                }
                dir.Files.Add(new ArcEntry {
                    Name = entry.Name, RawName = raw_name
                });
                ++file_count;
            }
            if (null != callback)
            {
                callback(file_count + 1, null, null);
            }

            int  callback_count = 0;
            long dir_offset     = 4 + file_table.Count * 12;
            long data_offset    = dir_offset + (arc_options.NameLength + 9) * file_count;

            output.Position = data_offset;
            foreach (var ext in file_table.Keys)
            {
                var dir = file_table[ext];
                dir.DirOffset = (uint)dir_offset;
                dir_offset   += (arc_options.NameLength + 9) * dir.Files.Count;
                foreach (var entry in dir.Files)
                {
                    if (null != callback)
                    {
                        callback(callback_count++, entry, arcStrings.MsgAddingFile);
                    }
                    entry.Offset = data_offset;
                    entry.Size   = WriteEntry(entry.Name, output);
                    data_offset += entry.Size;
                    if (data_offset > uint.MaxValue)
                    {
                        throw new FileSizeException();
                    }
                }
            }
            if (null != callback)
            {
                callback(callback_count++, null, arcStrings.MsgWritingIndex);
            }

            output.Position = 0;
            using (var header = new BinaryWriter(output, encoding, true))
            {
                byte[] buffer = new byte[arc_options.NameLength + 1];
                header.Write(file_table.Count);
                foreach (var ext in file_table)
                {
                    Buffer.BlockCopy(ext.Value.Extension, 0, buffer, 0, ext.Value.Extension.Length);
                    for (int i = ext.Value.Extension.Length; i < 4; ++i)
                    {
                        buffer[i] = 0;
                    }
                    header.Write(buffer, 0, 4);
                    header.Write(ext.Value.Files.Count);
                    header.Write(ext.Value.DirOffset);
                }
                foreach (var ext in file_table)
                {
                    foreach (var entry in ext.Value.Files)
                    {
                        Buffer.BlockCopy(entry.RawName, 0, buffer, 0, entry.RawName.Length);
                        for (int i = entry.RawName.Length; i < buffer.Length; ++i)
                        {
                            buffer[i] = 0;
                        }
                        header.Write(buffer);
                        header.Write(entry.Size);
                        header.Write((uint)entry.Offset);
                    }
                }
            }
        }
コード例 #3
0
ファイル: ArcWILL.cs プロジェクト: Casidi/GARbro
        public override void Create(Stream output, IEnumerable<Entry> list, ResourceOptions options,
                                     EntryCallback callback)
        {
            var arc_options = GetOptions<ArcOptions> (options);
            var encoding = Encodings.cp932.WithFatalFallback();

            int file_count = 0;
            var file_table = new SortedDictionary<string, ArcDirectory>();
            foreach (var entry in list)
            {
                string ext = Path.GetExtension (entry.Name).TrimStart ('.').ToUpperInvariant();
                if (string.IsNullOrEmpty (ext))
                    throw new InvalidFileName (entry.Name, arcStrings.MsgNoExtension);
                if (ext.Length > 3)
                    throw new InvalidFileName (entry.Name, arcStrings.MsgExtensionTooLong);
                string name = Path.GetFileNameWithoutExtension (entry.Name).ToUpperInvariant();
                byte[] raw_name = encoding.GetBytes (name);
                if (raw_name.Length > arc_options.NameLength)
                    throw new InvalidFileName (entry.Name, arcStrings.MsgFileNameTooLong);

                ArcDirectory dir;
                if (!file_table.TryGetValue (ext, out dir))
                {
                    byte[] raw_ext = encoding.GetBytes (ext);
                    if (raw_ext.Length > 3)
                        throw new InvalidFileName (entry.Name, arcStrings.MsgExtensionTooLong);
                    dir = new ArcDirectory { Extension = raw_ext, Files = new List<ArcEntry>() };
                    file_table[ext] = dir;
                }
                dir.Files.Add (new ArcEntry { Name = entry.Name, RawName = raw_name });
                ++file_count;
            }
            if (null != callback)
                callback (file_count+1, null, null);

            int callback_count = 0;
            long dir_offset = 4 + file_table.Count * 12;
            long data_offset = dir_offset + (arc_options.NameLength + 9) * file_count;
            output.Position = data_offset;
            foreach (var ext in file_table.Keys)
            {
                var dir = file_table[ext];
                dir.DirOffset = (uint)dir_offset;
                dir_offset += (arc_options.NameLength + 9) * dir.Files.Count;
                foreach (var entry in dir.Files)
                {
                    if (null != callback)
                        callback (callback_count++, entry, arcStrings.MsgAddingFile);
                    entry.Offset = data_offset;
                    entry.Size = WriteEntry (entry.Name, output);
                    data_offset += entry.Size;
                    if (data_offset > uint.MaxValue)
                        throw new FileSizeException();
                }
            }
            if (null != callback)
                callback (callback_count++, null, arcStrings.MsgWritingIndex);

            output.Position = 0;
            using (var header = new BinaryWriter (output, encoding, true))
            {
                byte[] buffer = new byte[arc_options.NameLength+1];
                header.Write (file_table.Count);
                foreach (var ext in file_table)
                {
                    Buffer.BlockCopy (ext.Value.Extension, 0, buffer, 0, ext.Value.Extension.Length);
                    for (int i = ext.Value.Extension.Length; i < 4; ++i)
                        buffer[i] = 0;
                    header.Write (buffer, 0, 4);
                    header.Write (ext.Value.Files.Count);
                    header.Write (ext.Value.DirOffset);
                }
                foreach (var ext in file_table)
                {
                    foreach (var entry in ext.Value.Files)
                    {
                        Buffer.BlockCopy (entry.RawName, 0, buffer, 0, entry.RawName.Length);
                        for (int i = entry.RawName.Length; i < buffer.Length; ++i)
                            buffer[i] = 0;
                        header.Write (buffer);
                        header.Write (entry.Size);
                        header.Write ((uint)entry.Offset);
                    }
                }
            }
        }