Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

禁止工程文件所在的目录和输出目录相同,防止意外丢失文件 #16

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion LuaSTGEditorSharp/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Collections.ObjectModel;
Expand Down Expand Up @@ -37,6 +37,7 @@

using Path = System.IO.Path;
using System.Reflection;
using LuaSTGEditorSharp.Packer;

namespace LuaSTGEditorSharp
{
Expand Down Expand Up @@ -496,6 +497,28 @@ public void Reveal(TreeNodeBase node)

private bool TestError()
{
// TODO: change directory check to generate error message and send to MessageContainer, prevent hard code here
App currentApp = Application.Current as App;
if (ActivatedWorkSpaceData != null && currentApp.PackerType == PlainCopyPacker.name)
{
ActivatedWorkSpaceData.GatherCompileInfo(currentApp);
if (!Uri.TryCreate(ActivatedWorkSpaceData.DocPath, UriKind.RelativeOrAbsolute, out Uri documentUri))
{
MessageBox.Show("Invalid document path.", "LuaSTG Editor Sharp", MessageBoxButton.OK, MessageBoxImage.Error);
return true;
}
if (!Uri.TryCreate(ActivatedWorkSpaceData.CompileProcess.Packer.TargetArchivePath, UriKind.RelativeOrAbsolute, out Uri targetUri))
{
MessageBox.Show("Invalid output directory.", "LuaSTG Editor Sharp", MessageBoxButton.OK, MessageBoxImage.Error);
return true;
}
if (documentUri.Equals(targetUri) || targetUri.IsBaseOf(documentUri))
{
MessageBox.Show("Project files are under output directory. The output directory will be deleted before build. DO NOT save project files in the output directory!"
, "LuaSTG Editor Sharp", MessageBoxButton.OK, MessageBoxImage.Error);
return true;
}
}
if (!MessageContainer.IsNoError())
{
tabMessage.IsSelected = true;
Expand Down
Loading