• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

djsuperchief / Kyameru / 8401706343

23 Mar 2024 12:18PM UTC coverage: 89.113% (-7.0%) from 96.15%
8401706343

push

github

web-flow
Merge pull request #104 from djsuperchief/103-release-config

103 release config

308 of 387 branches covered (79.59%)

Branch coverage included in aggregate %.

1812 of 1992 relevant lines covered (90.96%)

21.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.56
/source/components/Kyameru.Component.File/Implementation/Utilities/FileUtils.cs
1
using System;
2
using System.Collections.Generic;
3
using System.IO;
4
using System.Runtime.CompilerServices;
5
using System.Text;
6
using System.Threading;
7
using System.Threading.Tasks;
8

9
[assembly: InternalsVisibleTo("Kyameru.Component.File.Tests")]
10

11
namespace Kyameru.Component.File.Utilities
12
{
13
    internal class FileUtils : IFileUtils
14
    {
15
        public void WriteAllBytes(string path, byte[] file, bool overwrite = false)
16
        {
3✔
17
            if (overwrite)
3✔
18
            {
1✔
19
                this.OverwriteDestination(path);
1✔
20
            }
1✔
21

22
            System.IO.File.WriteAllBytes(path, file);
3✔
23
        }
3✔
24
        
25
        public async Task WriteAllBytesAsync(string path, byte[] file, bool overwrite, CancellationToken cancellationToken)
26
        {
1✔
27
            if (overwrite)
1!
28
            {
×
29
                this.OverwriteDestination(path);
×
30
            }
×
31

32
            await System.IO.File.WriteAllBytesAsync(path, file, cancellationToken);
1✔
33
        }
1✔
34

35
        public void WriteAllText(string path, string file, bool overwrite)
36
        {
3✔
37
            if(overwrite)
3✔
38
            {
1✔
39
                this.OverwriteDestination(path);
1✔
40
            }
1✔
41

42
            System.IO.File.WriteAllText(path, file);
3✔
43
        }
3✔
44
        
45
        public async Task WriteAllTextAsync(string path, string file, bool overwrite, CancellationToken cancellationToken)
46
        {
1✔
47
            if(overwrite)
1!
48
            {
×
49
                this.OverwriteDestination(path);
×
50
            }
×
51

52
            await System.IO.File.WriteAllTextAsync(path, file, cancellationToken);
1✔
53
        }
1✔
54

55
        public void Move(string source, string destination, bool overwrite = false)
56
        {
3✔
57
            if(overwrite)
3✔
58
            {
1✔
59
                this.OverwriteDestination(destination);
1✔
60
            }
1✔
61

62
            System.IO.File.Move(source, destination);
3✔
63
        }
3✔
64

65
        public Task MoveAsync(string source, string destination, bool overwrite, CancellationToken cancellationToken)
66
        {
1✔
67
            return Task.Factory.StartNew(() => System.IO.File.Move(source, destination), cancellationToken);
2✔
68
        }
1✔
69

70
        public Task CopyFileAsync(string source, string destination, bool overwrite, CancellationToken cancellationToken)
71
        {
1✔
72
            return Task.Factory.StartNew(() =>
1✔
73
            {
1✔
74
                if (overwrite)
1!
75
                {
×
76
                    this.OverwriteDestination(destination);
×
77
                }
×
78

1✔
79
                System.IO.File.Copy(source, destination);
1✔
80
            }, cancellationToken);
2✔
81
        }
1✔
82

83
        public void CreateDirectory(string directory) => System.IO.Directory.CreateDirectory(directory);
1✔
84
        public Task CreateDirectoryAsync(string directory, CancellationToken cancellationToken)
85
        {
×
86
            return Task.Factory.StartNew(() => System.IO.Directory.CreateDirectory(directory), cancellationToken);
×
87
        }
×
88

89
        public void CopyFile(string source, string destination, bool overwrite = false)
90
        {
3✔
91
            if(overwrite)
3✔
92
            {
1✔
93
                this.OverwriteDestination(destination);
1✔
94
            }
1✔
95

96
            System.IO.File.Copy(source, destination);
3✔
97
        }
3✔
98

99
        public void Delete(string file) => System.IO.File.Delete(file);
5✔
100

101
        public Task DeleteAsync(string file, CancellationToken cancellationToken)
102
        {
1✔
103
            return Task.Factory.StartNew(() => System.IO.File.Delete(file), cancellationToken);
2✔
104
        }
1✔
105

106
        private void OverwriteDestination(string file)
107
        {
4✔
108
            if(System.IO.File.Exists(file))
4✔
109
            {
4✔
110
                System.IO.File.Delete(file);
4✔
111
            }
4✔
112
        }
4✔
113
    }
114
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc