Skip to content

Commit ff05f7b

Browse files
author
A9G-Data-Droid
committed
Added assembly information,
1 parent 09a9d2b commit ff05f7b

4 files changed

Lines changed: 47 additions & 21 deletions

File tree

TextFileConvert/ConvertLineEndings.vb

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ Imports System.Text
33

44
Public Class ConvertLineEndings
55
''' <summary>
6-
''' These are the different conversions we can handle in this library
6+
''' These are the different conversions that this library can perform.
77
''' </summary>
88
Private Enum TextConvertMode
99
Dos2Ux
1010
Ux2Dos
11-
Dos2Mac
12-
Mac2Dos
13-
Mac2Ux
14-
Ux2Mac
11+
'Dos2Mac
12+
'Mac2Dos
13+
'Mac2Ux
14+
'Ux2Mac
1515
End Enum
1616

1717
''' <summary>
18-
''' Converts a DOS text file to have Unix line endings.
18+
''' Converts a DOS text file to have Unix line endings.
1919
''' </summary>
2020
''' <param name="originalFile">The file to convert.</param>
2121
''' <param name="newFile">The name of a new file to create.</param>
@@ -25,7 +25,7 @@ Public Class ConvertLineEndings
2525
End Function
2626

2727
''' <summary>
28-
''' Converts a DOS text file to have Unix line endings.
28+
''' Converts a DOS text file to have Unix line endings.
2929
''' </summary>
3030
''' <param name="originalFile">The file to convert.</param>
3131
''' <param name="newFile">The name of a new file to create.</param>
@@ -35,13 +35,14 @@ Public Class ConvertLineEndings
3535
End Function
3636

3737
''' <summary>
38-
''' Loads a whole text file in to memory, Performs a find\replace, and writes a new file.
38+
''' Loads a whole text file in to memory, Performs a find\replace, and writes a new file.
3939
''' </summary>
4040
''' <param name="originalFile">The file to convert.</param>
4141
''' <param name="newFile">The name of a new file to create.</param>
4242
''' <param name="convertMode">This is the type of conversion we are going to perform</param>
4343
''' <returns>Exit code.</returns>
44-
Private Shared Async Function ReplaceLineEndings(originalFile As String, newFile As String, convertMode As TextConvertMode) As Task(Of Integer)
44+
Private Shared Async Function ReplaceLineEndings(originalFile As String, newFile As String,
45+
convertMode As TextConvertMode) As Task(Of Integer)
4546
Const cr As Char = ChrW(13)
4647
Const lf As Char = ChrW(10)
4748

@@ -55,10 +56,10 @@ Public Class ConvertLineEndings
5556
Try
5657
oldFileStream = New FileStream(originalFile, FileMode.Open)
5758
Using oldFile As New StreamReader(oldFileStream, fileEncoding, True)
58-
Do Until oldFile.EndOfStream
59+
Do Until oldFile.EndOfStream ' Read through the whole file
5960
Dim readBuffer(0) As Char
6061
Dim readChars As Integer = Await oldFile.ReadAsync(readBuffer, 0, 1)
61-
If readChars < 1 Then Exit Do
62+
If readChars < 1 Then Exit Do ' Short circuit
6263
Select Case convertMode
6364
Case TextConvertMode.Dos2Ux
6465
If readBuffer(0) = cr AndAlso oldFile.Peek() = 10 Then
@@ -82,9 +83,11 @@ Public Class ConvertLineEndings
8283
Debug.Print("Unimplemented text conversion mode")
8384
Return -1
8485
End Select
86+
8587
convertedText.Append(readBuffer)
8688
Loop
8789
End Using
90+
8891
oldFileStream = Nothing
8992
Catch ex As Exception
9093
Debug.Print("Error: " & ex.Message & Environment.NewLine & "Number: " & ex.HResult.ToString)
@@ -105,14 +108,13 @@ Public Class ConvertLineEndings
105108
End Function
106109

107110
''' <summary>
108-
''' Attempt to detect the encoding of a file.
111+
''' Attempt to detect the encoding of a file.
109112
''' </summary>
110113
''' <param name="filename">The file to get the encoding pattern from.</param>
111-
''' <returns>Encoding type, defaults to ASCII</returns>
114+
''' <returns>Encoding type, defaults to ASCII.</returns>
112115
Public Shared Function GetEncoding(filename As String) As Encoding
113116
Dim bom = New Byte(3) {}
114-
115-
Try
117+
Try ' to read BOM
116118
Using file = New FileStream(filename, FileMode.Open, FileAccess.Read)
117119
file.Read(bom, 0, 4)
118120
End Using
@@ -121,11 +123,14 @@ Public Class ConvertLineEndings
121123
Return Nothing
122124
End Try
123125

126+
' Detect BOM type
124127
If bom(0) = &H2B AndAlso bom(1) = &H2F AndAlso bom(2) = &H76 Then Return Encoding.UTF7
125128
If bom(0) = &HEF AndAlso bom(1) = &HBB AndAlso bom(2) = &HBF Then Return Encoding.UTF8
126129
If bom(0) = &HFF AndAlso bom(1) = &HFE Then Return Encoding.Unicode
127130
If bom(0) = &HFE AndAlso bom(1) = &HFF Then Return Encoding.BigEndianUnicode
128131
If bom(0) = 0 AndAlso bom(1) = 0 AndAlso bom(2) = &HFE AndAlso bom(3) = &HFF Then Return Encoding.UTF32
132+
133+
' Default to
129134
Return Encoding.ASCII
130135
End Function
131136
End Class

TextFileConvert/TextFileConvert.vbproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
<PropertyGroup>
44
<RootNamespace>TextFileConvert</RootNamespace>
55
<TargetFramework>netstandard2.0</TargetFramework>
6+
<Authors>Adam Kauffman</Authors>
7+
<Company>Cascade Engineering Technologies</Company>
8+
<NeutralLanguage>en</NeutralLanguage>
9+
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
10+
<Description>This provides text file conversion capabilities like the common Unix utilities "ux2dos" and "dos2ux".</Description>
11+
<Copyright>Copyright 2018 Adam Kauffman</Copyright>
12+
<PackageLicenseUrl>https://opensource.org/licenses/MIT</PackageLicenseUrl>
13+
<AssemblyVersion>0.1.0.0</AssemblyVersion>
14+
<Version>0.1.0</Version>
15+
<PackageReleaseNotes>This is the alpha build.</PackageReleaseNotes>
16+
<PackageTags>ux2dos, dos2ux</PackageTags>
617
</PropertyGroup>
718

819
</Project>

dos2ux/dos2ux.vbproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
<TargetFramework>net461</TargetFramework>
77
<StartupObject>Sub Main</StartupObject>
88
<ApplicationManifest>My Project\app.manifest</ApplicationManifest>
9+
<Version>0.1.0</Version>
10+
<Authors>Adam Kauffman</Authors>
11+
<Company>Cascade Engineering Technologies</Company>
12+
<Description>This provides text file conversion capabilities like the common Unix tool.</Description>
13+
<Copyright>Copyright 2018 Adam Kauffman</Copyright>
14+
<PackageLicenseUrl>https://opensource.org/licenses/MIT</PackageLicenseUrl>
15+
<PackageReleaseNotes>This is the alpha build.</PackageReleaseNotes>
16+
<NeutralLanguage>en</NeutralLanguage>
917
</PropertyGroup>
1018

1119
<ItemGroup>

ux2dos/My Project/AssemblyInfo.vb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Imports System.Reflection
1+
Imports System.Resources
2+
Imports System.Reflection
23
Imports System.Runtime.InteropServices
34

45
' General Information about an assembly is controlled through the following
@@ -8,10 +9,10 @@ Imports System.Runtime.InteropServices
89
' Review the values of the assembly attributes
910

1011
<Assembly: AssemblyTitle("ux2dos")>
11-
<Assembly: AssemblyDescription("")>
12-
<Assembly: AssemblyCompany("Microsoft")>
12+
<Assembly: AssemblyDescription("Like the old UNIX command.")>
13+
<Assembly: AssemblyCompany("Cascade Engineering Technologies")>
1314
<Assembly: AssemblyProduct("ux2dos")>
14-
<Assembly: AssemblyCopyright("Copyright © Microsoft 2018")>
15+
<Assembly: AssemblyCopyright("Copyright © 2018 Adam Kauffman")>
1516
<Assembly: AssemblyTrademark("")>
1617

1718
<Assembly: ComVisible(False)>
@@ -30,5 +31,6 @@ Imports System.Runtime.InteropServices
3031
' by using the '*' as shown below:
3132
' <Assembly: AssemblyVersion("1.0.*")>
3233

33-
<Assembly: AssemblyVersion("1.0.0.0")>
34-
<Assembly: AssemblyFileVersion("1.0.0.0")>
34+
<Assembly: AssemblyVersion("0.1.0.0")>
35+
<Assembly: AssemblyFileVersion("0.1.0.0")>
36+
<Assembly: NeutralResourcesLanguage("en")>

0 commit comments

Comments
 (0)