File tree 3 files changed +52
-0
lines changed
3 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,11 @@ func (f *File) Name() string {
100
100
// assume only only one '.'
101
101
splitFileIdentifier := strings .Split (fileIdentifier , "." )
102
102
103
+ // there's no dot in the name, thus no extension
104
+ if len (splitFileIdentifier ) == 1 {
105
+ return splitFileIdentifier [0 ]
106
+ }
107
+
103
108
// extension is empty, return just the name without a dot
104
109
if len (splitFileIdentifier [1 ]) == 0 {
105
110
return splitFileIdentifier [0 ]
Original file line number Diff line number Diff line change
1
+ package iso9660
2
+
3
+ import (
4
+ "bytes"
5
+ "strings"
6
+ "testing"
7
+
8
+ "github.com/stretchr/testify/assert"
9
+ )
10
+
11
+ // Regresstion test for github.com/kdomanski/iso9660/issues/9
12
+ func TestRegressionNameWithoutDot (t * testing.T ) {
13
+ var buf bytes.Buffer
14
+
15
+ //
16
+ // create image with a file without dot
17
+ //
18
+ w , err := NewWriter ()
19
+ assert .NoError (t , err )
20
+ defer func () {
21
+ if cleanupErr := w .Cleanup (); cleanupErr != nil {
22
+ t .Fatalf ("failed to cleanup writer: %v" , cleanupErr )
23
+ }
24
+ }()
25
+
26
+ err = w .AddFile (strings .NewReader ("hrh2309hr320h" ), "NODOT" )
27
+ assert .NoError (t , err )
28
+
29
+ err = w .WriteTo (& buf , "testvolume" )
30
+ assert .NoError (t , err )
31
+
32
+ //
33
+ // no read it
34
+ //
35
+
36
+ image , err := OpenImage (bytes .NewReader (buf .Bytes ()))
37
+ assert .NoError (t , err )
38
+
39
+ rootDir , err := image .RootDir ()
40
+ assert .NoError (t , err )
41
+
42
+ children , err := rootDir .GetChildren ()
43
+ assert .NoError (t , err )
44
+
45
+ nodotfile := children [0 ]
46
+ assert .Equal (t , "nodot" , nodotfile .Name ())
47
+ }
You can’t perform that action at this time.
0 commit comments