22
33using File = TagLib . File ;
44
5- public class StripImageData
5+ namespace StripImageData ;
6+
7+ public class Program
68{
7- private static byte [ ] image_data = new byte [ ] {
9+ static readonly byte [ ] image_data = [
810 0xFF , 0xDA , 0x00 , 0x0C , 0x03 , 0x01 , 0x00 ,
911 0x02 , 0x11 , 0x03 , 0x11 , 0x00 , 0x3F , 0x00 ,
1012 0x8C , 0x80 , 0x07 , 0xFF , 0xD9
11- } ;
13+ ] ;
1214
1315 public static void Main ( string [ ] args )
1416 {
@@ -17,9 +19,9 @@ public static void Main (string [] args)
1719 return ;
1820 }
1921
20- ImageFile file = new ImageFile ( args [ 0 ] ) ;
21-
22- file . Mode = File . AccessMode . Write ;
22+ var file = new ImageFile ( args [ 0 ] ) {
23+ Mode = File . AccessMode . Write
24+ } ;
2325
2426 long greatest_segment_position = 0 ;
2527 long greatest_segment_length = 0 ;
@@ -48,25 +50,25 @@ public static void Main (string [] args)
4850 return ;
4951 }
5052
51- System . Console . WriteLine ( "Stripping data segment at {0}" , greatest_segment_position ) ;
53+ Console . WriteLine ( $ "Stripping data segment at { greatest_segment_position } " ) ;
5254
5355 file . RemoveBlock ( greatest_segment_position , greatest_segment_length ) ;
5456 file . Seek ( greatest_segment_position ) ;
5557 file . WriteBlock ( image_data ) ;
5658 file . Mode = File . AccessMode . Closed ;
5759 }
5860
59- private static long SkipDataSegment ( ImageFile file )
61+ static long SkipDataSegment ( ImageFile file )
6062 {
6163 long position = file . Tell ;
6264
6365 // skip sos maker
6466 if ( file . ReadBlock ( 2 ) . ToUInt ( ) != 0xFFDA )
65- throw new Exception ( String . Format ( "Not a data segment at position: {0}" , position ) ) ;
67+ throw new Exception ( $ "Not a data segment at position: { position } " ) ;
6668
6769 while ( true ) {
68- if ( 0xFF == ( byte ) file . ReadBlock ( 1 ) [ 0 ] ) {
69- byte maker = ( byte ) file . ReadBlock ( 1 ) [ 0 ] ;
70+ if ( 0xFF == file . ReadBlock ( 1 ) [ 0 ] ) {
71+ byte maker = file . ReadBlock ( 1 ) [ 0 ] ;
7072
7173 if ( maker != 0x00 && ( maker <= 0xD0 || maker >= 0xD7 ) )
7274 break ;
@@ -75,42 +77,41 @@ private static long SkipDataSegment (ImageFile file)
7577
7678 long length = file . Tell - position - 2 ;
7779
78- System . Console . WriteLine ( "Data segment of length {0 } found at {1}" , length , position ) ;
80+ Console . WriteLine ( $ "Data segment of length { length } found at { position } " ) ;
7981
8082 return length ;
8183 }
8284
83- private class ImageFile : File {
85+ class ImageFile : File {
8486
8587 // Hacky implementation to make use of some methods defined in TagLib.File
8688
87- public ImageFile ( string path )
88- : base ( new File . LocalFileAbstraction ( path ) ) { }
89+ public ImageFile ( string path ) : base ( new LocalFileAbstraction ( path ) ) { }
8990
90- public override Tag GetTag ( TagLib . TagTypes type , bool create )
91+ public override Tag GetTag ( TagTypes type , bool create )
9192 {
92- throw new System . NotImplementedException ( ) ;
93+ throw new NotImplementedException ( ) ;
9394 }
9495
9596 public override Properties Properties {
9697 get {
97- throw new System . NotImplementedException ( ) ;
98+ throw new NotImplementedException ( ) ;
9899 }
99100 }
100101
101- public override void RemoveTags ( TagLib . TagTypes types )
102+ public override void RemoveTags ( TagTypes types )
102103 {
103- throw new System . NotImplementedException ( ) ;
104+ throw new NotImplementedException ( ) ;
104105 }
105106
106107 public override void Save ( )
107108 {
108- throw new System . NotImplementedException ( ) ;
109+ throw new NotImplementedException ( ) ;
109110 }
110111
111112 public override Tag Tag {
112113 get {
113- throw new System . NotImplementedException ( ) ;
114+ throw new NotImplementedException ( ) ;
114115 }
115116 }
116117 }
0 commit comments