Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

Commit

Permalink
-update: better project folder support
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeromusXYZ committed Jun 29, 2019
1 parent 7c08104 commit 5b02968
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 38 deletions.
1 change: 1 addition & 0 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ private void TryOpenProjectFile(string ProjectFile)
{
projectDlg.LoadFromPacketTapPage(tp);
projectDlg.btnSave.Text = "Open";
projectDlg.cbOpenedLog.Enabled = true;
if (projectDlg.ShowDialog() == DialogResult.OK)
{
projectDlg.ApplyPacketTapPage();
Expand Down
19 changes: 17 additions & 2 deletions PVLVHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public List<List<string>> Extractor(string url)

static class Helper
{
private static List<string> ExpectedLogFileRoots = new List<string>() { "packetviewer", "logs", "packetdb", "wireshark", "packeteer", "idview", "raw" , "incoming" , "outgoing" , "in" , "out" };
private static List<string> ExpectedLogFileRoots = new List<string>() { "packetviewer", "logs", "packetdb", "wireshark", "packeteer", "idview", "raw" , "incoming" , "outgoing" , "in" , "out", "npclogger" };
private static List<string> ExpectedLogFolderRootsWithCharacterNames = new List<string>() { "packetviewer", "packetdb", "wireshark", "packeteer", "idview", "npclogger" };

// Source: https://stackoverflow.com/questions/275689/how-to-get-relative-path-from-absolute-path
/// <summary>
Expand Down Expand Up @@ -260,11 +261,25 @@ public static string MakeProjectDirectoryFromLogFileName(string filename)
if (pathSplit.Count >= 1)
pathSplit[0] = pathSplit[0] + Path.DirectorySeparatorChar; // manually add the \ back to the first split

List<string> elfr = new List<string>();
elfr.AddRange(ExpectedLogFileRoots);

while (pathSplit.Count > 1)
{
pathSplit.RemoveAt(pathSplit.Count - 1);
var hDir = pathSplit[pathSplit.Count - 1];
if ((ExpectedLogFileRoots.IndexOf(hDir) < 0) && (Directory.Exists(Path.Combine(pathSplit.ToArray()))))

if ( (pathSplit.Count > 2) && (ExpectedLogFolderRootsWithCharacterNames.IndexOf(pathSplit[pathSplit.Count - 2]) >= 0) )
{
// This is the first dir inside packetviewer, add support for character names
// Add "this character name" to expected dirs when downdir is packetviewer and currect dir isn't in expected
if ((elfr.IndexOf(hDir) < 0) && (Directory.Exists(Path.Combine(pathSplit.ToArray()))))
{
elfr.Add(hDir);
}
}

if ((elfr.IndexOf(hDir) < 0) && (Directory.Exists(Path.Combine(pathSplit.ToArray()))))
{
break;
}
Expand Down
2 changes: 0 additions & 2 deletions PacketDefs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public static class PacketColors
static public int PacketListStyle;
public static List<Color> DataColors = new List<Color>();


public static void UpdateColorsFromSettings()
{
ColBackIN = Properties.Settings.Default.ColBackIN;
Expand Down Expand Up @@ -122,7 +121,6 @@ public static void UpdateColorsFromSettings()
DataColors.Add(Color.Brown);
DataColors.Add(Color.MidnightBlue);
*/

}
}

Expand Down
54 changes: 27 additions & 27 deletions ProjectInfoForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 37 additions & 4 deletions ProjectInfoForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ private string VisualTagsToString()
return res;
}

private void AddLogOption(string fulldir)
{
string shortDir = PVLVHelper.Helper.MakeRelative(tp.ProjectFolder,fulldir);
cbOpenedLog.Items.Add(shortDir);
}

public void LoadFromPacketTapPage(PacketTabPage sourceTP)
{
tp = sourceTP;
Expand All @@ -91,11 +97,26 @@ public void LoadFromPacketTapPage(PacketTabPage sourceTP)
CreateVisualTags(tp.ProjectTags);
tTagBox.Text = "";
tProjectFolder.Text = tp.ProjectFolder;
tOpenedLog.Text = tp.LoadedLogFile;
cbOpenedLog.Text = tp.LoadedLogFile;
tSourceVideo.Text = tp.LinkVideoFileName;
tYoutubeURL.Text = tp.LinkYoutubeURL;
tPackedLogsURL.Text = tp.LinkPacketsDownloadURL;

cbOpenedLog.Items.Clear();
AddLogOption(tp.LoadedLogFile); // Current Log File
cbOpenedLog.Text = tp.LoadedLogFile;
var logfiles = Directory.GetFiles(tp.ProjectFolder, "*.log", SearchOption.AllDirectories);
var txtfiles = Directory.GetFiles(tp.ProjectFolder, "*.txt", SearchOption.AllDirectories);
var sqlfiles = Directory.GetFiles(tp.ProjectFolder, "*.sqlite", SearchOption.AllDirectories);
List<string> files = new List<string>();
files.AddRange(logfiles);
files.AddRange(txtfiles);
files.AddRange(sqlfiles);
foreach (var f in files)
{
if (!Path.GetFileName(f).ToLower().StartsWith("0x"))
AddLogOption(f);
}

gbProjectInfo.Text = "Project Information: " + Path.GetFileName(tp.ProjectFile);
}
}
Expand All @@ -106,7 +127,10 @@ public void ApplyPacketTapPage()
{
tp.ProjectTags = VisualTagsToString();
tp.ProjectFolder = tProjectFolder.Text;
tp.LoadedLogFile = tOpenedLog.Text;
if (File.Exists(tProjectFolder.Text + cbOpenedLog.Text))
tp.LoadedLogFile = tProjectFolder.Text + cbOpenedLog.Text;
else
tp.LoadedLogFile = cbOpenedLog.Text;
tp.LinkVideoFileName = tSourceVideo.Text;
tp.LinkYoutubeURL = tYoutubeURL.Text;
tp.LinkPacketsDownloadURL = tPackedLogsURL.Text;
Expand Down Expand Up @@ -312,7 +336,16 @@ private void ProjectInfo_TextChanged(object sender, EventArgs e)
}

// Attached Log file
if (File.Exists(tOpenedLog.Text))
if (File.Exists(cbOpenedLog.Text))
{
lOpenedLogOK.Text = "\x81";
lOpenedLogOK.ForeColor = Color.LimeGreen;
// Disable download/extract when we have a valid file
btnExtractZip.Enabled = false;
btnDownloadSource.Enabled = false;
}
else
if (File.Exists(tProjectFolder.Text + cbOpenedLog.Text))
{
lOpenedLogOK.Text = "\x81";
lOpenedLogOK.ForeColor = Color.LimeGreen;
Expand Down
2 changes: 1 addition & 1 deletion ProjectInfoForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAC2
DwAAAk1TRnQBSQFMAgEBBwEAATgBAAE4AQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
DwAAAk1TRnQBSQFMAgEBBwEAAUABAAFAAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.6.0.0")]
[assembly: AssemblyFileVersion("0.6.0.0")]
[assembly: AssemblyVersion("0.6.1.0")]
[assembly: AssemblyFileVersion("0.6.1.0")]

0 comments on commit 5b02968

Please sign in to comment.