2011-09-27 05:19:01 +02:00
|
|
|
|
/* This file is part of Sharpii.
|
|
|
|
|
* Copyright (C) 2011 Person66
|
|
|
|
|
*
|
|
|
|
|
* Sharpii is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* Sharpii is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2011-11-02 02:02:11 +01:00
|
|
|
|
* along with Sharpii. If not, see <http://www.gnu.org/licenses/>.
|
2011-09-27 05:19:01 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2011-11-02 02:02:11 +01:00
|
|
|
|
using System.Net;
|
2011-09-27 05:19:01 +02:00
|
|
|
|
using libWiiSharp;
|
|
|
|
|
|
|
|
|
|
namespace Sharpii
|
|
|
|
|
{
|
|
|
|
|
class MainApp
|
|
|
|
|
{
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Length < 1)
|
|
|
|
|
{
|
|
|
|
|
help();
|
2011-10-03 05:43:22 +02:00
|
|
|
|
Environment.Exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!File.Exists("libWiiSharp.dll"))
|
|
|
|
|
{
|
|
|
|
|
System.Console.WriteLine("ERROR: libWiiSharp.dll not found");
|
2011-11-02 02:02:11 +01:00
|
|
|
|
System.Console.WriteLine("\n\nAttemp to download? [Y/N]");
|
|
|
|
|
System.Console.Write("\n>>");
|
|
|
|
|
string ans = Console.ReadLine();
|
|
|
|
|
if (ans.ToUpper() == "Y")
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Console.Write("\nGrabbing libWiiSharp.dll...");
|
|
|
|
|
WebClient DLwadInstaller = new WebClient();
|
|
|
|
|
DLwadInstaller.DownloadFile("http://sharpii.googlecode.com/svn/trunk/Sharpii/libWiiSharp.dll", "libWiiSharp.dll");
|
|
|
|
|
Console.Write("Done!\n");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{ System.Console.WriteLine("An error occured: {0}", ex.Message); Environment.Exit(0); }
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Environment.Exit(0);
|
2011-09-27 05:19:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i < args.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
switch (args[i].ToUpper())
|
|
|
|
|
{
|
|
|
|
|
case "-QUIET":
|
|
|
|
|
Quiet.quiet = 1;
|
|
|
|
|
break;
|
|
|
|
|
case "-Q":
|
|
|
|
|
Quiet.quiet = 1;
|
|
|
|
|
break;
|
|
|
|
|
case "-LOTS":
|
|
|
|
|
Quiet.quiet = 3;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string Function = args[0];
|
2011-11-02 02:02:11 +01:00
|
|
|
|
bool gotSomewhere = false;
|
2011-09-27 05:19:01 +02:00
|
|
|
|
|
|
|
|
|
if (Function.ToUpper() == "-H" || Function.ToUpper() == "-HELP" || Function.ToUpper() == "H" || Function.ToUpper() == "HELP")
|
|
|
|
|
{
|
|
|
|
|
help();
|
2011-11-02 02:02:11 +01:00
|
|
|
|
gotSomewhere = true;
|
2011-09-27 05:19:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Function.ToUpper() == "BNS")
|
|
|
|
|
{
|
|
|
|
|
BNS_Stuff.BNS(args);
|
2011-11-02 02:02:11 +01:00
|
|
|
|
gotSomewhere = true;
|
2011-09-27 05:19:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Function.ToUpper() == "WAD")
|
|
|
|
|
{
|
|
|
|
|
WAD_Stuff.WAD(args);
|
2011-11-02 02:02:11 +01:00
|
|
|
|
gotSomewhere = true;
|
2011-09-27 05:19:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Function.ToUpper() == "TPL")
|
|
|
|
|
{
|
|
|
|
|
TPL_Stuff.TPL(args);
|
2011-11-02 02:02:11 +01:00
|
|
|
|
gotSomewhere = true;
|
2011-09-27 05:19:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Function.ToUpper() == "U8")
|
|
|
|
|
{
|
|
|
|
|
U8_Stuff.U8(args);
|
2011-11-02 02:02:11 +01:00
|
|
|
|
gotSomewhere = true;
|
2011-09-27 05:19:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Function.ToUpper() == "IOS")
|
|
|
|
|
{
|
|
|
|
|
IOS_Stuff.IOS(args);
|
2011-11-02 02:02:11 +01:00
|
|
|
|
gotSomewhere = true;
|
2011-09-27 05:19:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-09-30 17:05:58 +02:00
|
|
|
|
if (Function.ToUpper() == "NUS" || Function.ToUpper() == "NUSD")
|
|
|
|
|
{
|
|
|
|
|
NUS_Stuff.NUS(args);
|
2011-11-02 02:02:11 +01:00
|
|
|
|
gotSomewhere = true;
|
2011-09-30 17:05:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-09-27 05:19:01 +02:00
|
|
|
|
if (Function.ToUpper() == "SENDDOL" || Function.ToUpper() == "SENDOL")
|
|
|
|
|
{
|
|
|
|
|
HBC_Stuff.SendDol(args);
|
2011-11-02 02:02:11 +01:00
|
|
|
|
gotSomewhere = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Function.ToUpper() == "SENDWAD")
|
|
|
|
|
{
|
|
|
|
|
bool cont = HBC_Stuff.SendWad_Check(args);
|
|
|
|
|
if (cont == true) HBC_Stuff.SendWad(args);
|
|
|
|
|
gotSomewhere = true;
|
2011-09-27 05:19:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-11-02 02:02:11 +01:00
|
|
|
|
if (gotSomewhere == false)
|
|
|
|
|
{
|
|
|
|
|
//If tuser gets here, they entered something wrong
|
|
|
|
|
System.Console.WriteLine("ERROR: The argument {0} is invalid", args[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string temp = Path.GetTempPath() + "Sharpii.tmp";
|
|
|
|
|
if (Directory.Exists(temp) == true)
|
|
|
|
|
DeleteDir.DeleteDirectory(temp);
|
2011-09-27 05:19:01 +02:00
|
|
|
|
|
|
|
|
|
Environment.Exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void help()
|
|
|
|
|
{
|
|
|
|
|
System.Console.WriteLine("");
|
|
|
|
|
System.Console.WriteLine("Sharpii {0} - A tool by person66, using libWiiSharp.dll by leathl", Version.version);
|
|
|
|
|
System.Console.WriteLine("");
|
|
|
|
|
System.Console.WriteLine("");
|
|
|
|
|
System.Console.WriteLine(" Usage:");
|
|
|
|
|
System.Console.WriteLine("");
|
|
|
|
|
System.Console.WriteLine(" Sharpii [function] [parameters] [-quiet | -q | -lots]");
|
|
|
|
|
System.Console.WriteLine("");
|
|
|
|
|
System.Console.WriteLine("");
|
|
|
|
|
System.Console.WriteLine(" Functions:");
|
|
|
|
|
System.Console.WriteLine("");
|
|
|
|
|
System.Console.WriteLine(" BNS Convert a wav to bns, or vice versa");
|
|
|
|
|
System.Console.WriteLine(" WAD Pack/Unpack/Edit a wad file");
|
|
|
|
|
System.Console.WriteLine(" TPL Convert a image to a tpl, or vice versa");
|
|
|
|
|
System.Console.WriteLine(" U8 Pack/Unpack a U8 archive");
|
|
|
|
|
System.Console.WriteLine(" IOS Apply various patches to an IOS");
|
2011-09-30 17:05:58 +02:00
|
|
|
|
System.Console.WriteLine(" NUSD Download files from NUS");
|
2011-09-27 05:19:01 +02:00
|
|
|
|
System.Console.WriteLine(" SendDol Send a dol to the HBC over wifi");
|
2011-11-02 02:02:11 +01:00
|
|
|
|
System.Console.WriteLine(" SendWad Send a wad to the HBC over wifi");
|
2011-09-27 05:19:01 +02:00
|
|
|
|
System.Console.WriteLine("");
|
|
|
|
|
System.Console.WriteLine(" NOTE: Too see more detailed descriptions of any of the above,");
|
|
|
|
|
System.Console.WriteLine(" use 'Sharpii [function] -h'");
|
|
|
|
|
System.Console.WriteLine("");
|
|
|
|
|
System.Console.WriteLine("");
|
|
|
|
|
System.Console.WriteLine(" Global Arguments:");
|
|
|
|
|
System.Console.WriteLine("");
|
|
|
|
|
System.Console.WriteLine(" -quiet | -q Try not to display any output");
|
|
|
|
|
System.Console.WriteLine(" -lots Display lots of output");
|
|
|
|
|
System.Console.WriteLine("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-10-11 04:48:10 +02:00
|
|
|
|
public class DeleteDir
|
|
|
|
|
{
|
|
|
|
|
public static bool DeleteDirectory(string target_dir)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
|
|
|
|
|
string[] files = Directory.GetFiles(target_dir);
|
|
|
|
|
string[] dirs = Directory.GetDirectories(target_dir);
|
|
|
|
|
|
|
|
|
|
foreach (string file in files)
|
|
|
|
|
{
|
|
|
|
|
File.SetAttributes(file, FileAttributes.Normal);
|
|
|
|
|
File.Delete(file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (string dir in dirs)
|
|
|
|
|
{
|
|
|
|
|
DeleteDirectory(dir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Directory.Delete(target_dir, false);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-09-27 05:19:01 +02:00
|
|
|
|
public class Quiet {
|
|
|
|
|
//1 = little
|
|
|
|
|
//2 = normal
|
|
|
|
|
//3 = lots
|
|
|
|
|
public static int quiet = 2;
|
|
|
|
|
}
|
|
|
|
|
public class Version
|
|
|
|
|
{
|
2011-11-02 02:02:11 +01:00
|
|
|
|
public static string version = "1.5";
|
2011-09-27 05:19:01 +02:00
|
|
|
|
}
|