File tree Expand file tree Collapse file tree 2 files changed +64
-0
lines changed Expand file tree Collapse file tree 2 files changed +64
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . IO ;
4
+ using System . Linq ;
5
+
6
+ namespace Semmle . Util
7
+ {
8
+ /// <summary>
9
+ /// Utility to temporarily rename a set of files.
10
+ /// </summary>
11
+ public sealed class FileRenamer : IDisposable
12
+ {
13
+ readonly string [ ] files ;
14
+ const string suffix = ".codeqlhidden" ;
15
+
16
+ public FileRenamer ( IEnumerable < FileInfo > oldFiles )
17
+ {
18
+ files = oldFiles . Select ( f => f . FullName ) . ToArray ( ) ;
19
+
20
+ foreach ( var file in files )
21
+ {
22
+ File . Move ( file , file + suffix ) ;
23
+ }
24
+ }
25
+
26
+ public void Dispose ( )
27
+ {
28
+ foreach ( var file in files )
29
+ {
30
+ File . Move ( file + suffix , file ) ;
31
+ }
32
+ }
33
+ }
34
+ }
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . IO ;
3
+ using System . Linq ;
4
+ using System . Security . Cryptography ;
5
+ using System . Text ;
6
+
7
+ namespace Semmle . Util
8
+ {
9
+ /// <summary>
10
+ /// A temporary directory that is created within the system temp directory.
11
+ /// When this object is disposed, the directory is deleted.
12
+ /// </summary>
13
+ public sealed class TemporaryDirectory : IDisposable
14
+ {
15
+ public DirectoryInfo DirInfo { get ; }
16
+
17
+ public TemporaryDirectory ( string name )
18
+ {
19
+ DirInfo = new DirectoryInfo ( name ) ;
20
+ DirInfo . Create ( ) ;
21
+ }
22
+
23
+ public void Dispose ( )
24
+ {
25
+ DirInfo . Delete ( true ) ;
26
+ }
27
+
28
+ public override string ToString ( ) => DirInfo . FullName . ToString ( ) ;
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments