Skip to content

Commit 0ca48b7

Browse files
committed
MaxGrab
1 parent 38a15b8 commit 0ca48b7

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

FastFileCopy/FastFileCopy.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
<TargetFramework>net6.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8+
<AssemblyVersion>1.0.0.3</AssemblyVersion>
9+
<FileVersion>1.0.0.3</FileVersion>
10+
</PropertyGroup>
11+
12+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
13+
<DebugType>embedded</DebugType>
14+
</PropertyGroup>
15+
16+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
17+
<DebugType>embedded</DebugType>
818
</PropertyGroup>
919

1020
<ItemGroup>

FastFileCopy/Program.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ static async Task Main(string[] args)
4646
int flag5 = 5;
4747
string? flag6 = null;
4848
int flag7 = 1;
49+
int flag8 = -1;
4950

5051
//Operation
5152
try { flag2 = (Operation)int.Parse(args[2]); } catch { }
@@ -65,6 +66,9 @@ static async Task Main(string[] args)
6566
//RecurseSubdirectories
6667
try { _ = int.TryParse(args[7], out flag7); } catch { }
6768

69+
//MaxGrab
70+
try { _ = int.TryParse(args[8], out flag8); } catch { }
71+
6872

6973
if (string.IsNullOrEmpty(SourcePath))
7074
{
@@ -97,14 +101,16 @@ static async Task Main(string[] args)
97101
MatchCasing = MatchCasing.CaseInsensitive
98102
};
99103

100-
var files = Directory.EnumerateFiles(SourcePath, flag6, enumerationOptions).ToList();
104+
var files = Directory.EnumerateFiles(SourcePath, flag6, enumerationOptions);
105+
106+
var lFiles = (flag8 > 0) ? files.Take(flag8).ToList() : files.ToList();
101107

102-
files.Shuffle();
108+
lFiles.Shuffle();
103109

104110
if (flag4 == Logging.Yes)
105111
{
106112
sw1.Stop();
107-
Console.WriteLine($"files {files.Count()} listing files took {sw1.ElapsedMilliseconds}ms ");
113+
Console.WriteLine($"files {lFiles.Count()} listing files took {sw1.ElapsedMilliseconds}ms ");
108114

109115
}
110116

@@ -115,7 +121,7 @@ static async Task Main(string[] args)
115121
sw2.Start();
116122

117123

118-
await Parallel.ForEachAsync(files, new ParallelOptions()
124+
await Parallel.ForEachAsync(lFiles, new ParallelOptions()
119125
{
120126
MaxDegreeOfParallelism = flag3
121127
},

FastFileCopy/help.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Optional
1111
Abort integer Default = 5
1212
SearchPattern string Default = "*"
1313
RecurseSubdirectories integer Default = 1(On)
14+
MaxGrab integer Default = AllFiles
1415

1516

1617
E.g., Copy everything from temp1 to temp2 using 10 threads including subdirectories and store console output to log.txt

0 commit comments

Comments
 (0)