├── .gitignore
├── NSPsplitty.sln
├── NSPsplitty
├── App.config
├── App.xaml
├── App.xaml.cs
├── CopySplit.cs
├── CopyUnsplit.cs
├── Icon1.ico
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── MainWindowViewModel.cs
├── NSPsplitty.csproj
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── QuickSplit.cs
├── QuickUnsplit .cs
└── preview.png
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015/2017 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # Visual Studio 2017 auto generated files
33 | Generated\ Files/
34 |
35 | # MSTest test Results
36 | [Tt]est[Rr]esult*/
37 | [Bb]uild[Ll]og.*
38 |
39 | # NUNIT
40 | *.VisualState.xml
41 | TestResult.xml
42 |
43 | # Build Results of an ATL Project
44 | [Dd]ebugPS/
45 | [Rr]eleasePS/
46 | dlldata.c
47 |
48 | # Benchmark Results
49 | BenchmarkDotNet.Artifacts/
50 |
51 | # .NET Core
52 | project.lock.json
53 | project.fragment.lock.json
54 | artifacts/
55 | **/Properties/launchSettings.json
56 |
57 | # StyleCop
58 | StyleCopReport.xml
59 |
60 | # Files built by Visual Studio
61 | *_i.c
62 | *_p.c
63 | *_i.h
64 | *.ilk
65 | *.meta
66 | *.obj
67 | *.iobj
68 | *.pch
69 | *.pdb
70 | *.ipdb
71 | *.pgc
72 | *.pgd
73 | *.rsp
74 | *.sbr
75 | *.tlb
76 | *.tli
77 | *.tlh
78 | *.tmp
79 | *.tmp_proj
80 | *.log
81 | *.vspscc
82 | *.vssscc
83 | .builds
84 | *.pidb
85 | *.svclog
86 | *.scc
87 |
88 | # Chutzpah Test files
89 | _Chutzpah*
90 |
91 | # Visual C++ cache files
92 | ipch/
93 | *.aps
94 | *.ncb
95 | *.opendb
96 | *.opensdf
97 | *.sdf
98 | *.cachefile
99 | *.VC.db
100 | *.VC.VC.opendb
101 |
102 | # Visual Studio profiler
103 | *.psess
104 | *.vsp
105 | *.vspx
106 | *.sap
107 |
108 | # Visual Studio Trace Files
109 | *.e2e
110 |
111 | # TFS 2012 Local Workspace
112 | $tf/
113 |
114 | # Guidance Automation Toolkit
115 | *.gpState
116 |
117 | # ReSharper is a .NET coding add-in
118 | _ReSharper*/
119 | *.[Rr]e[Ss]harper
120 | *.DotSettings.user
121 |
122 | # JustCode is a .NET coding add-in
123 | .JustCode
124 |
125 | # TeamCity is a build add-in
126 | _TeamCity*
127 |
128 | # DotCover is a Code Coverage Tool
129 | *.dotCover
130 |
131 | # AxoCover is a Code Coverage Tool
132 | .axoCover/*
133 | !.axoCover/settings.json
134 |
135 | # Visual Studio code coverage results
136 | *.coverage
137 | *.coveragexml
138 |
139 | # NCrunch
140 | _NCrunch_*
141 | .*crunch*.local.xml
142 | nCrunchTemp_*
143 |
144 | # MightyMoose
145 | *.mm.*
146 | AutoTest.Net/
147 |
148 | # Web workbench (sass)
149 | .sass-cache/
150 |
151 | # Installshield output folder
152 | [Ee]xpress/
153 |
154 | # DocProject is a documentation generator add-in
155 | DocProject/buildhelp/
156 | DocProject/Help/*.HxT
157 | DocProject/Help/*.HxC
158 | DocProject/Help/*.hhc
159 | DocProject/Help/*.hhk
160 | DocProject/Help/*.hhp
161 | DocProject/Help/Html2
162 | DocProject/Help/html
163 |
164 | # Click-Once directory
165 | publish/
166 |
167 | # Publish Web Output
168 | *.[Pp]ublish.xml
169 | *.azurePubxml
170 | # Note: Comment the next line if you want to checkin your web deploy settings,
171 | # but database connection strings (with potential passwords) will be unencrypted
172 | *.pubxml
173 | *.publishproj
174 |
175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
176 | # checkin your Azure Web App publish settings, but sensitive information contained
177 | # in these scripts will be unencrypted
178 | PublishScripts/
179 |
180 | # NuGet Packages
181 | *.nupkg
182 | # The packages folder can be ignored because of Package Restore
183 | **/[Pp]ackages/*
184 | # except build/, which is used as an MSBuild target.
185 | !**/[Pp]ackages/build/
186 | # Uncomment if necessary however generally it will be regenerated when needed
187 | #!**/[Pp]ackages/repositories.config
188 | # NuGet v3's project.json files produces more ignorable files
189 | *.nuget.props
190 | *.nuget.targets
191 |
192 | # Microsoft Azure Build Output
193 | csx/
194 | *.build.csdef
195 |
196 | # Microsoft Azure Emulator
197 | ecf/
198 | rcf/
199 |
200 | # Windows Store app package directories and files
201 | AppPackages/
202 | BundleArtifacts/
203 | Package.StoreAssociation.xml
204 | _pkginfo.txt
205 | *.appx
206 |
207 | # Visual Studio cache files
208 | # files ending in .cache can be ignored
209 | *.[Cc]ache
210 | # but keep track of directories ending in .cache
211 | !*.[Cc]ache/
212 |
213 | # Others
214 | ClientBin/
215 | ~$*
216 | *~
217 | *.dbmdl
218 | *.dbproj.schemaview
219 | *.jfm
220 | *.pfx
221 | *.publishsettings
222 | orleans.codegen.cs
223 |
224 | # Including strong name files can present a security risk
225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
226 | #*.snk
227 |
228 | # Since there are multiple workflows, uncomment next line to ignore bower_components
229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
230 | #bower_components/
231 |
232 | # RIA/Silverlight projects
233 | Generated_Code/
234 |
235 | # Backup & report files from converting an old project file
236 | # to a newer Visual Studio version. Backup files are not needed,
237 | # because we have git ;-)
238 | _UpgradeReport_Files/
239 | Backup*/
240 | UpgradeLog*.XML
241 | UpgradeLog*.htm
242 | ServiceFabricBackup/
243 | *.rptproj.bak
244 |
245 | # SQL Server files
246 | *.mdf
247 | *.ldf
248 | *.ndf
249 |
250 | # Business Intelligence projects
251 | *.rdl.data
252 | *.bim.layout
253 | *.bim_*.settings
254 | *.rptproj.rsuser
255 |
256 | # Microsoft Fakes
257 | FakesAssemblies/
258 |
259 | # GhostDoc plugin setting file
260 | *.GhostDoc.xml
261 |
262 | # Node.js Tools for Visual Studio
263 | .ntvs_analysis.dat
264 | node_modules/
265 |
266 | # Visual Studio 6 build log
267 | *.plg
268 |
269 | # Visual Studio 6 workspace options file
270 | *.opt
271 |
272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
273 | *.vbw
274 |
275 | # Visual Studio LightSwitch build output
276 | **/*.HTMLClient/GeneratedArtifacts
277 | **/*.DesktopClient/GeneratedArtifacts
278 | **/*.DesktopClient/ModelManifest.xml
279 | **/*.Server/GeneratedArtifacts
280 | **/*.Server/ModelManifest.xml
281 | _Pvt_Extensions
282 |
283 | # Paket dependency manager
284 | .paket/paket.exe
285 | paket-files/
286 |
287 | # FAKE - F# Make
288 | .fake/
289 |
290 | # JetBrains Rider
291 | .idea/
292 | *.sln.iml
293 |
294 | # CodeRush
295 | .cr/
296 |
297 | # Python Tools for Visual Studio (PTVS)
298 | __pycache__/
299 | *.pyc
300 |
301 | # Cake - Uncomment if you are using it
302 | # tools/**
303 | # !tools/packages.config
304 |
305 | # Tabs Studio
306 | *.tss
307 |
308 | # Telerik's JustMock configuration file
309 | *.jmconfig
310 |
311 | # BizTalk build output
312 | *.btp.cs
313 | *.btm.cs
314 | *.odx.cs
315 | *.xsd.cs
316 |
317 | # OpenCover UI analysis results
318 | OpenCover/
319 |
320 | # Azure Stream Analytics local run output
321 | ASALocalRun/
322 |
323 | # MSBuild Binary and Structured Log
324 | *.binlog
325 |
326 | # NVidia Nsight GPU debugger configuration file
327 | *.nvuser
328 |
329 | # MFractors (Xamarin productivity tool) working folder
330 | .mfractor/
331 |
--------------------------------------------------------------------------------
/NSPsplitty.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29306.81
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NSPsplitty", "NSPsplitty\NSPsplitty.csproj", "{63610E80-3771-4493-A92E-A993A444B3BE}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {63610E80-3771-4493-A92E-A993A444B3BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {63610E80-3771-4493-A92E-A993A444B3BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {63610E80-3771-4493-A92E-A993A444B3BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {63610E80-3771-4493-A92E-A993A444B3BE}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {B57EC70E-C15E-4E43-B875-2F3417E39453}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/NSPsplitty/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/NSPsplitty/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/NSPsplitty/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace NSPsplitty
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/NSPsplitty/CopySplit.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace NSPsplitty
5 | {
6 | public partial class MainWindow
7 | {
8 | private void SplitCopy()
9 | {
10 | try
11 | {
12 | var remSize = fileSize;
13 | using (FileStream nspfile = File.OpenRead(fileDir))
14 | {
15 |
16 | for (int i = 0; i < splitNumber + 1; ++i)
17 | {
18 | ConsoleText(string.Format("Starting part {0:00}.", i));
19 |
20 | using (FileStream splitFile = File.OpenWrite(dir + string.Format("\\{0:00}", i)))
21 | {
22 | long size = 0, tempSize = 0, lastSize = 0, checkSize = splitSize;
23 | byte[] buffer = new byte[chunkSize];
24 |
25 | if (remSize < splitSize) { checkSize = remSize; }
26 | var checkMB = checkSize / 1024 / 1024;
27 | //(size = new FileInfo(splitFile.Name).Length)
28 | while (size < checkSize)
29 | {
30 | splitFile.Write(buffer, 0,
31 | nspfile.Read(buffer, 0, buffer.Length));
32 | size += chunkSize;
33 | lastSize = size / 1024 / 1024;
34 |
35 | if (lastSize <= tempSize) { continue; }
36 |
37 | tempSize = lastSize;
38 | ConsoleText($" {lastSize}MB / {checkMB}MB", true, ".");
39 | }
40 |
41 | remSize -= splitSize;
42 |
43 | splitFile.Flush();
44 | splitFile.Dispose();
45 |
46 | ConsoleText(string.Format(" Part {0:00} completed", i));
47 | }
48 | }
49 |
50 | nspfile.Flush();
51 | nspfile.Dispose();
52 | }
53 |
54 | File.SetAttributes(dir, FileAttributes.Archive);
55 | ConsoleText("\n NSP splitted sccuessfully");
56 |
57 | this.Dispatcher.Invoke(new Action(() =>
58 | {
59 | Split_Button.IsEnabled = true;
60 | }));
61 |
62 | }catch(Exception exception)
63 | {
64 | ConsoleText(exception.Message);
65 | ConsoleText(exception.StackTrace);
66 | }
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/NSPsplitty/CopyUnsplit.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace NSPsplitty
5 | {
6 | public partial class MainWindow
7 | {
8 | private void CopyUnsplit()
9 | {
10 | try
11 | {
12 | using (var createdFile = File.Create(dir + dir.Substring(dir.LastIndexOf("\\"))))
13 | {
14 | for(int i = 0; i < splitNumber; ++i)
15 | {
16 |
17 | using (var indexFile = File.OpenRead(dir+string.Format("\\{0:00}",i)))
18 | {
19 | ConsoleText($"Starting to merge file {indexFile.Name.Substring(indexFile.Name.LastIndexOf("\\"))}.");
20 |
21 | long size = 0, indexSize = new FileInfo(indexFile.Name).Length;
22 | long lastSize = 0, tempSize = 0, checkMB;
23 |
24 | checkMB = indexSize / 1024 / 1024;
25 | byte[] buffer = new byte[chunkSize];
26 |
27 | while(size < indexSize)
28 | {
29 | createdFile.Write(buffer, 0,
30 | indexFile.Read(buffer, 0, buffer.Length));
31 | size += chunkSize;
32 |
33 | lastSize = size / 1024 / 1024;
34 |
35 | if (lastSize <= tempSize) { continue; }
36 |
37 | tempSize = lastSize;
38 | ConsoleText($" {lastSize}MB / {checkMB}MB", true, ".");
39 | }
40 |
41 | ConsoleText($" file {indexFile.Name.Substring(indexFile.Name.LastIndexOf("\\"))} merged completed.");
42 |
43 | indexFile.Flush();
44 | indexFile.Dispose();
45 | }
46 | }
47 |
48 | createdFile.Flush();
49 | createdFile.Dispose();
50 | }
51 | ConsoleText($"\n {dir.Substring(dir.LastIndexOf(".")).ToUpper()} merged sccuessfully");
52 | }
53 | catch (Exception exception)
54 | {
55 | ConsoleText(exception.Message);
56 | ConsoleText(exception.StackTrace);
57 | }
58 |
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/NSPsplitty/Icon1.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aionmagan/NSPsplitty/3b0b94ff650f89fd167d924a1b2a7bd536556c85/NSPsplitty/Icon1.ico
--------------------------------------------------------------------------------
/NSPsplitty/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/NSPsplitty/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Threading;
4 | using Microsoft.Win32;
5 | using System.Windows;
6 |
7 | namespace NSPsplitty
8 | {
9 | ///
10 | /// Interaction logic for MainWindow.xaml
11 | ///
12 |
13 | public partial class MainWindow : Window
14 | {
15 | private MainWindowViewModel viewModel = new MainWindowViewModel();
16 |
17 | private string fileDir
18 | {
19 | get => viewModel.InputFile;
20 | set => viewModel.InputFile = value;
21 | }
22 |
23 | private string dir
24 | {
25 | get => viewModel.OutputDir;
26 | set => viewModel.OutputDir = value;
27 | }
28 | private string dotExtension = null;
29 | private bool mergeFile = false;
30 | private long fileSize = 0;
31 | private long splitNumber = 0;
32 | private readonly uint splitSize = 0xFFFF0000;
33 | private readonly uint chunkSize = 0x8000;
34 |
35 | public MainWindow()
36 | {
37 | InitializeComponent();
38 | this.DataContext = viewModel;
39 | }
40 |
41 | private void MergeState(bool merge)
42 | {
43 | if (merge == true)
44 | {
45 | SearchBox.Text = "Browse for the file you will like to Merge";
46 | Split_Button.Content = "Merge files";
47 | } else
48 | {
49 | SearchBox.Text = "Browse for the file you will like to split";
50 | Split_Button.Content = "Split File";
51 | }
52 | //Split_Button.IsEnabled = false;
53 | mergeFile = merge;
54 | }
55 |
56 | private void ConsoleText(string str, bool rewrite = false, string indexOf = ".")
57 | {
58 | if (Thread.CurrentThread != ConsoleBox.Dispatcher.Thread)
59 | {
60 | this.Dispatcher.Invoke(new Action(() =>
61 | {
62 | ConsoleText(str, rewrite, indexOf);
63 | }));
64 | return;
65 | }
66 |
67 | if (rewrite)
68 | {
69 | ConsoleBox.Text = ConsoleBox.Text.Substring(0, ConsoleBox.Text.LastIndexOf(indexOf)+1)+"\n"+str+"\n";
70 | }
71 | else
72 | {
73 | ConsoleBox.Text += str + "\n";
74 | }
75 |
76 | ConsoleBox.Focus();
77 | ConsoleBox.CaretIndex = ConsoleBox.Text.Length;
78 | ConsoleBox.ScrollToEnd();
79 | }
80 |
81 | private void Browse_Click(object sender, RoutedEventArgs e)
82 | {
83 | OpenFileDialog openFile = new OpenFileDialog();
84 | openFile.Multiselect = false;
85 | openFile.Filter = "NSP(*.nsp*)|*.nsp*| All files(*.*)|*.*";
86 |
87 | Nullable checkFile = openFile.ShowDialog();
88 | MergeState(false);
89 |
90 | if (checkFile == true)
91 | {
92 | fileDir = openFile.FileName;
93 |
94 | /*better way to check for all 'xx'(01, 02,...) or equal files
95 | * by looking for a missing (.) at the end
96 | * will apply later for testing
97 | * for now it will require file '00' to enable merge
98 | */
99 | if (fileDir.Substring(fileDir.LastIndexOf("\\")) == "\\00")
100 | {
101 | dir = fileDir.Substring(0, fileDir.LastIndexOf("\\"));
102 | MergeState(true);
103 | }
104 |
105 | if(fileDir != null)
106 | {
107 | //cleaning consoleText
108 | ConsoleBox.Text = "";
109 | //ConsoleText($"file extension is {dotExtension}");
110 | splitNumber = 0;
111 | Split_Button.IsEnabled = true;
112 | }
113 | }
114 | }
115 |
116 | private void Split_Click(object sender, RoutedEventArgs e)
117 | {
118 | //cleaning consoleText
119 | ConsoleBox.Text = "";
120 | Split_Button.IsEnabled = false;
121 |
122 | //getting drive for where the file is located (C/D ect...)
123 | DriveInfo drive = new DriveInfo(fileDir[0].ToString());
124 | fileSize = new FileInfo(fileDir).Length;
125 |
126 | //double code, need to optimize, works for now
127 | if (mergeFile)
128 | {
129 | //starting a 1 because 00 was already apply 6 above this one
130 | int i = 1;
131 | while (File.Exists(dir + string.Format("\\{0:00}", i)))
132 | {
133 | fileSize += new FileInfo(dir + string.Format("\\{0:00}", i)).Length;
134 | i++;
135 | }
136 | }
137 |
138 | long tempsize = fileSize;
139 | if (Create_Copy.IsChecked == true) { tempsize *= 2; }
140 |
141 | if (tempsize > drive.TotalFreeSpace)
142 | {
143 | string str = ((float)(tempsize - drive.TotalFreeSpace) / 1024 / 1024 / 1024).ToString();
144 | str = str.Substring(0, str.IndexOf(".") + 3);
145 |
146 | ConsoleText("Not Enought Free Space \n" + str + "GB needed", false);
147 | }
148 | else
149 | {
150 |
151 | Thread thread;
152 | if (Create_Copy.IsChecked == true)
153 | {
154 | if (mergeFile)
155 | {
156 | if (CalculateUnsplit())
157 | {
158 | thread = new Thread(CopyUnsplit);
159 | thread.Priority = ThreadPriority.Highest;
160 | thread.Start();
161 | }
162 | }
163 | else
164 | {
165 | if (CalculateSplits())
166 | {
167 | thread = new Thread(SplitCopy);
168 | thread.Priority = ThreadPriority.Highest;
169 | thread.Start();
170 | }
171 | }
172 |
173 | }
174 | else
175 | {
176 | if (mergeFile)
177 | {
178 | if (CalculateUnsplit())
179 | {
180 | thread = new Thread(QuickUnsplit);
181 | thread.Priority = ThreadPriority.Highest;
182 | thread.Start();
183 | }
184 | }
185 | else
186 | {
187 | if (CalculateSplits())
188 | {
189 | thread = new Thread(SplitQuick);
190 | thread.Priority = ThreadPriority.Highest;
191 | thread.Start();
192 | }
193 | }
194 | }
195 |
196 | }
197 | }
198 |
199 | private bool CalculateUnsplit()
200 | {
201 | //checking for amounts of files '0x'
202 | do
203 | {
204 | splitNumber++;
205 |
206 | } while (File.Exists(dir + string.Format("\\{0:00}", splitNumber)));
207 |
208 | ConsoleText($"folder contains {splitNumber} mergeable files");
209 |
210 |
211 | if (splitNumber <= 1)
212 | {
213 | ConsoleText($"{splitNumber} is not enough to merge files");
214 | return false;
215 | }
216 |
217 | return true;
218 | }
219 |
220 | private bool CalculateSplits()
221 | {
222 | ConsoleText("Calculating numbers of split files...\n");
223 |
224 | splitNumber = (fileSize / splitSize);
225 |
226 | if (splitNumber == 0)
227 | {
228 | ConsoleText($"This {dotExtension} file is under 4GB, no split is needed");
229 |
230 | return false;
231 | }
232 |
233 | dotExtension = fileDir.Substring(fileDir.LastIndexOf("."));
234 | ConsoleText($" Splitting {dotExtension} into {splitNumber + 1} parts");
235 | dir = fileDir.Substring(0, fileDir.LastIndexOf(".")) + "_split"+dotExtension;
236 |
237 | if (Directory.Exists(dir)) { Directory.Delete(dir, true); }
238 | Directory.CreateDirectory(dir);
239 |
240 | return true;
241 | }
242 |
243 |
244 | }
245 | }
246 |
--------------------------------------------------------------------------------
/NSPsplitty/MainWindowViewModel.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Runtime.CompilerServices;
3 |
4 | namespace NSPsplitty
5 | {
6 | internal class MainWindowViewModel : INotifyPropertyChanged
7 | {
8 | private string m_FileToSplit = null;
9 | private string m_Dir = null;
10 |
11 | public event PropertyChangedEventHandler PropertyChanged;
12 |
13 | private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
14 | {
15 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
16 | }
17 |
18 | public string OutputDir
19 | {
20 | get => m_Dir;
21 | set
22 | {
23 | if (value != m_Dir)
24 | {
25 | m_Dir = value;
26 | NotifyPropertyChanged();
27 | }
28 | }
29 | }
30 |
31 | public string InputFile
32 | {
33 | get => m_FileToSplit;
34 | set
35 | {
36 | if (value != m_FileToSplit)
37 | {
38 | m_FileToSplit = value;
39 | NotifyPropertyChanged();
40 | }
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/NSPsplitty/NSPsplitty.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {63610E80-3771-4493-A92E-A993A444B3BE}
8 | WinExe
9 | NSPsplitty
10 | NSPsplitty
11 | v4.7.2
12 | 512
13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
14 | 4
15 | true
16 | true
17 |
18 |
19 | AnyCPU
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | DEBUG;TRACE
25 | prompt
26 | 4
27 |
28 |
29 | AnyCPU
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 | Icon1.ico
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | 4.0
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | MSBuild:Compile
64 | Designer
65 |
66 |
67 |
68 |
69 |
70 |
71 | MSBuild:Compile
72 | Designer
73 |
74 |
75 | App.xaml
76 | Code
77 |
78 |
79 |
80 | MainWindow.xaml
81 | Code
82 |
83 |
84 |
85 |
86 | Code
87 |
88 |
89 | True
90 | True
91 | Resources.resx
92 |
93 |
94 | True
95 | Settings.settings
96 | True
97 |
98 |
99 | ResXFileCodeGenerator
100 | Resources.Designer.cs
101 |
102 |
103 | SettingsSingleFileGenerator
104 | Settings.Designer.cs
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/NSPsplitty/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("NSPsplitty")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("NSPsplitty")]
15 | [assembly: AssemblyCopyright("Copyright © 2019")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/NSPsplitty/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace NSPsplitty.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NSPsplitty.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/NSPsplitty/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/NSPsplitty/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace NSPsplitty.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/NSPsplitty/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/NSPsplitty/QuickSplit.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace NSPsplitty
5 | {
6 | public partial class MainWindow
7 | {
8 | private void SplitQuick()
9 | {
10 | try
11 | {
12 | ConsoleText(string.Format(" Split is happening from file '{0:00}' to file '01'", splitNumber));
13 |
14 | //moving and rename original file to '00'
15 | Directory.Move(fileDir, dir + "\\00");
16 |
17 | var sizeOfSplit = fileSize - (splitSize * splitNumber);
18 | var splitNum = splitNumber;
19 | var checkMB = (sizeOfSplit / 1024 / 1024);
20 |
21 | //splitting starting from the last file and making it file '01'
22 | //truncating file '00' on the fly
23 | using (var nspFile = File.Open(dir + "\\00", FileMode.Open, FileAccess.ReadWrite))
24 | {
25 | for (int i = -1; i < splitNumber - 1; ++i)
26 | {
27 | if(i >= 0)
28 | {
29 | sizeOfSplit = splitSize;
30 | splitNum = (splitNumber - (i + 1));
31 | checkMB = (sizeOfSplit / 1024 / 1024);
32 | }
33 |
34 | nspFile.Seek(sizeOfSplit * -1, SeekOrigin.End);
35 |
36 | ConsoleText(string.Format("Starting part {0:00}.", splitNum));
37 | using (var splitFile = File.OpenWrite(dir + string.Format("\\{0:00}", splitNum)))
38 | {
39 | long size = 0, tempSize = 0, lastSize = 0;
40 | byte[] buffer = new byte[chunkSize];
41 | //(size = new FileInfo(splitFile.Name).Length)
42 | while (size < sizeOfSplit)
43 | {
44 | splitFile.Write(buffer, 0,
45 | nspFile.Read(buffer, 0, buffer.Length));
46 | size += chunkSize;
47 | lastSize = size / 1024 / 1024;
48 | if (lastSize <= tempSize) { continue; }
49 |
50 | tempSize = lastSize;
51 | ConsoleText($" {lastSize}MB / {checkMB}MB", true, ".");
52 | }
53 |
54 | splitFile.Flush();
55 | splitFile.Dispose();
56 | }
57 |
58 | nspFile.SetLength(nspFile.Seek(sizeOfSplit * -1, SeekOrigin.End));
59 | ConsoleText(string.Format(" Part {0:00} completed", splitNum));
60 | }
61 |
62 | nspFile.Flush();
63 | nspFile.Dispose();
64 | }
65 |
66 | File.SetAttributes(dir, FileAttributes.Archive);
67 | ConsoleText("\n NSP split successfully");
68 |
69 | }catch(Exception exception)
70 | {
71 | ConsoleText(exception.Message);
72 | ConsoleText(exception.StackTrace);
73 | }
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/NSPsplitty/QuickUnsplit .cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace NSPsplitty
5 | {
6 | public partial class MainWindow
7 | {
8 | private void QuickUnsplit()
9 | {
10 | try
11 | {
12 | //moving and rename original file to 'foldername.EXTENSION'
13 | if (File.Exists(dir + "\\" + dir.Substring(dir.LastIndexOf("\\"))))
14 | {
15 | File.Delete(dir + "\\" + dir.Substring(dir.LastIndexOf("\\")));
16 | }
17 |
18 | Directory.Move(dir + "\\00", dir+"\\"+dir.Substring(dir.LastIndexOf("\\")));
19 |
20 | using (var openFile = File.Open(dir + "\\" + dir.Substring(dir.LastIndexOf("\\")), FileMode.Append, FileAccess.Write))
21 | {
22 | for (int i = (int)splitNumber - 1; i > 0; --i)
23 | {
24 | long size = 0, indexSize = 0;
25 | long lastSize = 0, tempSize = 0, checkMB = 0;
26 | byte[] buffer = new byte[chunkSize];
27 |
28 | using (var indexFile = File.OpenRead(dir + string.Format("\\{0:00}", i)))
29 | {
30 | ConsoleText($"Starting to merge file {indexFile.Name.Substring(indexFile.Name.LastIndexOf("\\"))}.");
31 | indexSize = new FileInfo(indexFile.Name).Length;
32 | checkMB = indexSize / 1024 / 1024;
33 |
34 | while (size < indexSize)
35 | {
36 | openFile.Write(buffer, 0,
37 | indexFile.Read(buffer, 0, buffer.Length));
38 | size += chunkSize;
39 |
40 | lastSize = size / 1024 / 1024;
41 |
42 | if (lastSize <= tempSize) { continue; }
43 |
44 | tempSize = lastSize;
45 | ConsoleText($" {lastSize}MB / {checkMB}MB", true, ".");
46 | }
47 |
48 | ConsoleText($" file {indexFile.Name.Substring(indexFile.Name.LastIndexOf("\\"))} merged completed.");
49 |
50 | indexFile.Flush();
51 | indexFile.Dispose();
52 |
53 | File.Delete(dir+string.Format("\\{0:00}", i));
54 | //ConsoleText(dir + string.Format("\\{0:00}", i));
55 | }
56 |
57 | }
58 |
59 | openFile.Flush();
60 | openFile.Dispose();
61 | }
62 | ConsoleText($"\n {dir.Substring(dir.LastIndexOf(".")).ToUpper()} merged sccuessfully");
63 | }
64 | catch (Exception exception)
65 | {
66 | ConsoleText(exception.Message);
67 | ConsoleText(exception.StackTrace);
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/NSPsplitty/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aionmagan/NSPsplitty/3b0b94ff650f89fd167d924a1b2a7bd536556c85/NSPsplitty/preview.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # NSPsplitty
2 |
3 | this is a general purpose tool for splitting or merging files to fit in the 'fat32' file system
4 | for all purposes (the name was given to make it obvious that Nintedo Switch files also counts) .
5 |
6 | it was made as a more straight forward tool with a graphical interface.
7 |
8 | ## Requirements
9 | Windows (confirmed to work on 7/8/8.1/10)
10 | .NET 4.7=>
11 |
12 | it was heavily inspired by the work of **AnalogMan151**
13 | link: https://github.com/AnalogMan151/splitNSP
14 |
15 | if you want to use such a tool on any other OS then please use AnalogMan's work;
16 | to understand the use of this tool more deeply go read up on his git
17 | and check his amazing documentation on how splitting files for the switch works.
18 |
19 | short hand to use this tool
20 |
21 | ## Browse button
22 | browse to file location (split folder or merge file will also be created in the same location)
23 | ## Copy Check box:
24 | create a copy or not (leaving it checked is recommended, requires double the storage space of the file selected)
25 | ## Split button / Merge button
26 | start splitting files or merging them
27 | 'Merge files' button will appear only if file '00'is selected (Updates v0.03-a require this)
28 | ## Console box
29 | reports activity for the user to know what's currently happening
30 | ## Merge check box (removed on update v0.03-a and above)
31 | select this first before choosing the file to merge (the merge button will appear)
32 |
33 | ## Preview
34 | 
35 |
--------------------------------------------------------------------------------