-
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
0 parents
commit 1b0d66f
Showing
13 changed files
with
889 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Roman Wanner | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,133 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
using System.IO; | ||
|
||
namespace CopyMod | ||
{ | ||
internal static class Backend | ||
{ | ||
internal static string settingsFile { get; private set; } = Application.StartupPath + @"\app.cfg"; | ||
internal static string sourceDir; | ||
internal static string destDir; | ||
internal static bool overwrite; | ||
internal static string[] filetypes = new string[0]; | ||
|
||
internal static void AddFileType(string ft) | ||
{ | ||
if (ContainsFileType(ft)) | ||
return; | ||
List<string> fts = new List<string>(); | ||
fts.AddRange(filetypes); | ||
fts.Add(ft); | ||
filetypes = fts.ToArray(); | ||
} | ||
|
||
internal static void RemoveFileType(string ft) | ||
{ | ||
List<string> fts = new List<string>(); | ||
foreach (string filetype in filetypes) | ||
if (filetype != ft) | ||
fts.Add(filetype); | ||
filetypes = fts.ToArray(); | ||
} | ||
|
||
internal static bool ContainsFileType(string ft) | ||
{ | ||
foreach (string filetype in filetypes) | ||
if (filetype == ft) | ||
return true; | ||
return false; | ||
} | ||
internal static bool LoadSettings() | ||
{ | ||
if(File.Exists(settingsFile)) | ||
{ | ||
string[] flines = File.ReadAllLines(settingsFile); | ||
if(flines.Length < 4) | ||
{ | ||
return false; | ||
} | ||
sourceDir = flines[0]; | ||
destDir = flines[1]; | ||
overwrite = bool.Parse(flines[2]); | ||
filetypes = flines[3].Split(','); | ||
return true; | ||
} | ||
sourceDir = ""; | ||
destDir = ""; | ||
overwrite = false; | ||
filetypes = new string[0]; | ||
return true; | ||
} | ||
|
||
internal static void SaveSettings() | ||
{ | ||
string ftstr = ""; | ||
foreach(string ft in filetypes) | ||
{ | ||
if(ftstr == "") | ||
{ | ||
ftstr = ft; | ||
} | ||
else | ||
{ | ||
ftstr += "," + ft; | ||
} | ||
} | ||
string[] flines = new string[4] {sourceDir, destDir, overwrite.ToString(), ftstr}; | ||
if (File.Exists(settingsFile)) | ||
File.Delete(settingsFile); | ||
File.WriteAllLines(settingsFile, flines); | ||
} | ||
|
||
internal static bool CopyContent(string[] extensions) | ||
{ | ||
if (filetypes.Length < 1) | ||
{ | ||
MessageBox.Show("You need to choose at least one filetype!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); | ||
return false; | ||
} | ||
if (sourceDir == "") | ||
{ | ||
MessageBox.Show("You need to choose a source directory!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); | ||
return false; | ||
} | ||
if (destDir == "") | ||
{ | ||
MessageBox.Show("You need to choose a destination directory!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); | ||
return false; | ||
} | ||
if (!Directory.Exists(sourceDir)) | ||
{ | ||
MessageBox.Show("The source directory couldn't be found! Did you delete it?", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); | ||
return false; | ||
} | ||
if (!Directory.Exists(destDir)) | ||
Directory.CreateDirectory(destDir); | ||
|
||
var files = (from file in Directory.EnumerateFiles(sourceDir,"*",SearchOption.TopDirectoryOnly) | ||
where extensions.Contains(Path.GetExtension(file), StringComparer.InvariantCultureIgnoreCase) | ||
select new | ||
{ | ||
Source = file, | ||
Destination = Path.Combine(destDir, Path.GetFileName(file)) | ||
}); | ||
foreach (var file in files) | ||
{ | ||
try | ||
{ | ||
File.Copy(file.Source, file.Destination, overwrite); | ||
} | ||
catch(Exception ex) | ||
{ | ||
MessageBox.Show(ex.Message); | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
} | ||
} |
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,79 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{B54664CF-308D-4C24-9314-2284D8F81E6F}</ProjectGuid> | ||
<OutputType>WinExe</OutputType> | ||
<RootNamespace>CopyMod</RootNamespace> | ||
<AssemblyName>CopyMod</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Deployment" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Windows.Forms" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Backend.cs" /> | ||
<Compile Include="Main.cs"> | ||
<SubType>Form</SubType> | ||
</Compile> | ||
<Compile Include="Main.Designer.cs"> | ||
<DependentUpon>Main.cs</DependentUpon> | ||
</Compile> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<EmbeddedResource Include="Main.resx"> | ||
<DependentUpon>Main.cs</DependentUpon> | ||
</EmbeddedResource> | ||
<EmbeddedResource Include="Properties\Resources.resx"> | ||
<Generator>ResXFileCodeGenerator</Generator> | ||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
<SubType>Designer</SubType> | ||
</EmbeddedResource> | ||
<Compile Include="Properties\Resources.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
</Compile> | ||
<None Include="Properties\Settings.settings"> | ||
<Generator>SettingsSingleFileGenerator</Generator> | ||
<LastGenOutput>Settings.Designer.cs</LastGenOutput> | ||
</None> | ||
<Compile Include="Properties\Settings.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Settings.settings</DependentUpon> | ||
<DesignTimeSharedInput>True</DesignTimeSharedInput> | ||
</Compile> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
Oops, something went wrong.