forked from XAYRGA/ibnktool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.cs
57 lines (53 loc) · 1.64 KB
/
util.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Be.IO;
namespace ibnktool
{
public static class util
{
public static bool consoleProgress_quiet = false;
public static void consoleProgress(string txt, int progress, int max, bool show_progress = false)
{
if (consoleProgress_quiet)
return;
var flt_total = (float)progress / max;
Console.CursorLeft = 0;
//Console.WriteLine(flt_total);
Console.Write($"{txt} [");
for (float i = 0; i < 32; i++)
if (flt_total > (i / 32f))
Console.Write("#");
else
Console.Write(" ");
Console.Write("]");
if (show_progress)
Console.Write($" ({progress}/{max})");
}
public static int padTo(BeBinaryWriter bw, int padding)
{
int del = 0;
while (bw.BaseStream.Position % padding != 0)
{
bw.BaseStream.WriteByte(0x00);
bw.BaseStream.Flush();
del++;
}
return del;
}
public static int[] readInt32Array(BeBinaryReader binStream, int count)
{
var b = new int[count];
for (int i = 0; i < count; i++)
b[i] = binStream.ReadInt32();
return b;
}
public static int padToInt(int Addr, int padding)
{
var delta = (int)(Addr % padding);
return (padding - delta);
}
}
}