forked from BeyondDimension/SteamTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
1,581 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
<Project> | ||
<PropertyGroup Condition="'$(Configuration)'=='Release'"> | ||
<DebugType>none</DebugType> | ||
<DebugSymbols>false</DebugSymbols> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<LangVersion>9.0</LangVersion> | ||
<Nullable>enable</Nullable> | ||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="Exists('..\Unicorn.pfx')"> | ||
|
||
<PropertyGroup Condition=" Exists('$(MSBuildProjectDirectory)\..\Unicorn.pfx') "> | ||
<DefineConstants>SIGN_ASSEMBLY;$(DefineConstants)</DefineConstants> | ||
<SignAssembly>true</SignAssembly> | ||
<DelaySign>false</DelaySign> | ||
<AssemblyOriginatorKeyFile>..\Unicorn.pfx</AssemblyOriginatorKeyFile> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition=" '$(Configuration)'=='Release' "> | ||
<DebugType>none</DebugType> | ||
<DebugSymbols>false</DebugSymbols> | ||
</PropertyGroup> | ||
</Project> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
using ICSharpCode.SharpZipLib.Tar; | ||
using System; | ||
using System.Application; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Windows.Forms; | ||
|
||
namespace Packager | ||
{ | ||
public partial class Form1 : Form | ||
{ | ||
readonly string app_path = @"\System.Application.SteamTools.Client.Desktop.Avalonia.App\bin\Release\Publish\win-x64"; | ||
|
||
static string GetPath(string path) | ||
{ | ||
if (Path.DirectorySeparatorChar == '\\') return path; | ||
return path.Replace('\\', Path.DirectorySeparatorChar); | ||
} | ||
|
||
public Form1() | ||
{ | ||
InitializeComponent(); | ||
textBox1.Text = GetPath(GetProjectPath() + app_path); | ||
} | ||
|
||
static string GetProjectPath(string? path = null) | ||
{ | ||
path ??= AppContext.BaseDirectory; | ||
if (!Directory.GetFiles(path, "*.sln").Any()) | ||
{ | ||
var parent = Directory.GetParent(path); | ||
if (parent == null) return string.Empty; | ||
return GetProjectPath(parent.FullName); | ||
} | ||
return path; | ||
} | ||
|
||
void OnBtnSelectPathClick(object sender, EventArgs e) | ||
{ | ||
if (openFileDialog1.ShowDialog() == DialogResult.OK) | ||
{ | ||
textBox1.Text = Path.GetDirectoryName(openFileDialog1.FileName); | ||
} | ||
} | ||
|
||
string? filePath = null; | ||
|
||
private void OnBtnCreateClick(object sender, EventArgs e) | ||
{ | ||
var dirPath = textBox1.Text; | ||
var parent = Directory.GetParent(dirPath)?.FullName; | ||
if (parent != null) | ||
{ | ||
filePath = Path.Combine(parent, DateTime.Now.ToString("yyyyMMddHHmmssfffffff")) + FileEx.TAR_GZ; | ||
TarGZipHelper.Create(filePath, dirPath, progress: ShowTarProgressMessage); | ||
} | ||
else | ||
{ | ||
richTextBox1.AppendText("Fail, Parent is null"); | ||
richTextBox1.AppendText(Environment.NewLine); | ||
} | ||
} | ||
|
||
void ShowTarProgressMessage(TarArchive archive, TarEntry entry, string message) | ||
{ | ||
if (entry.TarHeader.TypeFlag != TarHeader.LF_NORMAL && entry.TarHeader.TypeFlag != TarHeader.LF_OLDNORM) | ||
{ | ||
richTextBox1.AppendText("Entry type " + (char)entry.TarHeader.TypeFlag + " found!"); | ||
richTextBox1.AppendText(Environment.NewLine); | ||
} | ||
richTextBox1.AppendText(entry.Name + " " + message); | ||
richTextBox1.AppendText(Environment.NewLine); | ||
string modeString = DecodeType(entry.TarHeader.TypeFlag, entry.Name.EndsWith("/")) + DecodeMode(entry.TarHeader.Mode); | ||
string userString = (string.IsNullOrEmpty(entry.UserName)) ? entry.UserId.ToString() : entry.UserName; | ||
string groupString = (string.IsNullOrEmpty(entry.GroupName)) ? entry.GroupId.ToString() : entry.GroupName; | ||
richTextBox1.AppendText(string.Format("{0} {1}/{2} {3,8} {4:yyyy-MM-dd HH:mm:ss}", modeString, userString, groupString, entry.Size, entry.ModTime.ToLocalTime())); | ||
richTextBox1.AppendText(Environment.NewLine); | ||
} | ||
|
||
static string DecodeType(int type, bool slashTerminated) | ||
{ | ||
string result = "?"; | ||
switch (type) | ||
{ | ||
case TarHeader.LF_OLDNORM: // -jr- TODO this decoding is incomplete, not all possible known values are decoded... | ||
case TarHeader.LF_NORMAL: | ||
case TarHeader.LF_LINK: | ||
if (slashTerminated) | ||
result = "d"; | ||
else | ||
result = "-"; | ||
break; | ||
|
||
case TarHeader.LF_DIR: | ||
result = "d"; | ||
break; | ||
|
||
case TarHeader.LF_GNU_VOLHDR: | ||
result = "V"; | ||
break; | ||
|
||
case TarHeader.LF_GNU_MULTIVOL: | ||
result = "M"; | ||
break; | ||
|
||
case TarHeader.LF_CONTIG: | ||
result = "C"; | ||
break; | ||
|
||
case TarHeader.LF_FIFO: | ||
result = "p"; | ||
break; | ||
|
||
case TarHeader.LF_SYMLINK: | ||
result = "l"; | ||
break; | ||
|
||
case TarHeader.LF_CHR: | ||
result = "c"; | ||
break; | ||
|
||
case TarHeader.LF_BLK: | ||
result = "b"; | ||
break; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
static string DecodeMode(int mode) | ||
{ | ||
|
||
const int S_ISUID = 0x0800; | ||
const int S_ISGID = 0x0400; | ||
const int S_ISVTX = 0x0200; | ||
|
||
const int S_IRUSR = 0x0100; | ||
const int S_IWUSR = 0x0080; | ||
const int S_IXUSR = 0x0040; | ||
|
||
const int S_IRGRP = 0x0020; | ||
const int S_IWGRP = 0x0010; | ||
const int S_IXGRP = 0x0008; | ||
|
||
const int S_IROTH = 0x0004; | ||
const int S_IWOTH = 0x0002; | ||
const int S_IXOTH = 0x0001; | ||
|
||
|
||
var result = new System.Text.StringBuilder(); | ||
result.Append((mode & S_IRUSR) != 0 ? 'r' : '-'); | ||
result.Append((mode & S_IWUSR) != 0 ? 'w' : '-'); | ||
result.Append((mode & S_ISUID) != 0 | ||
? ((mode & S_IXUSR) != 0 ? 's' : 'S') | ||
: ((mode & S_IXUSR) != 0 ? 'x' : '-')); | ||
result.Append((mode & S_IRGRP) != 0 ? 'r' : '-'); | ||
result.Append((mode & S_IWGRP) != 0 ? 'w' : '-'); | ||
result.Append((mode & S_ISGID) != 0 | ||
? ((mode & S_IXGRP) != 0 ? 's' : 'S') | ||
: ((mode & S_IXGRP) != 0 ? 'x' : '-')); | ||
result.Append((mode & S_IROTH) != 0 ? 'r' : '-'); | ||
result.Append((mode & S_IWOTH) != 0 ? 'w' : '-'); | ||
result.Append((mode & S_ISVTX) != 0 | ||
? ((mode & S_IXOTH) != 0 ? 't' : 'T') | ||
: ((mode & S_IXOTH) != 0 ? 'x' : '-')); | ||
|
||
return result.ToString(); | ||
} | ||
|
||
private void OnBtnUnpackClick(object sender, EventArgs e) | ||
{ | ||
if (filePath != null) | ||
{ | ||
var dirName = Path.GetFileName(filePath).Split('.').First(); | ||
TarGZipHelper.Unpack(filePath, | ||
Path.Combine(Path.GetDirectoryName(filePath).ThrowIsNull(nameof(filePath)), dirName), ShowTarProgressMessage); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<root> | ||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | ||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> | ||
<xsd:element name="root" msdata:IsDataSet="true"> | ||
<xsd:complexType> | ||
<xsd:choice maxOccurs="unbounded"> | ||
<xsd:element name="metadata"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" use="required" type="xsd:string" /> | ||
<xsd:attribute name="type" type="xsd:string" /> | ||
<xsd:attribute name="mimetype" type="xsd:string" /> | ||
<xsd:attribute ref="xml:space" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="assembly"> | ||
<xsd:complexType> | ||
<xsd:attribute name="alias" type="xsd:string" /> | ||
<xsd:attribute name="name" type="xsd:string" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="data"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> | ||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | ||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | ||
<xsd:attribute ref="xml:space" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="resheader"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" type="xsd:string" use="required" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
</xsd:choice> | ||
</xsd:complexType> | ||
</xsd:element> | ||
</xsd:schema> | ||
<resheader name="resmimetype"> | ||
<value>text/microsoft-resx</value> | ||
</resheader> | ||
<resheader name="version"> | ||
<value>2.0</value> | ||
</resheader> | ||
<resheader name="reader"> | ||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
</resheader> | ||
<resheader name="writer"> | ||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
</resheader> | ||
</root> |
Oops, something went wrong.