diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2022-11-06 17:27:56 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-16 21:39:36 +0300 |
| commit | b8c9cdc9996706047b605fcb179161a678fcb8db (patch) | |
| tree | 9e8b7b345e8e9a6533ed4e1a7257b78f5f01ec8d /utils/utils.go | |
| parent | class parses and other stuff (diff) | |
| download | sdp.go-b8c9cdc9996706047b605fcb179161a678fcb8db.tar.gz sdp.go-b8c9cdc9996706047b605fcb179161a678fcb8db.tar.bz2 sdp.go-b8c9cdc9996706047b605fcb179161a678fcb8db.zip | |
changed github username + other stuff that i don't remember
Diffstat (limited to 'utils/utils.go')
| -rw-r--r-- | utils/utils.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/utils/utils.go b/utils/utils.go index d25fa36..db1b02f 100644 --- a/utils/utils.go +++ b/utils/utils.go | |||
| @@ -1,10 +1,11 @@ | |||
| 1 | package utils | 1 | package utils |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "bytes" | ||
| 4 | "os" | 5 | "os" |
| 5 | "unsafe" | 6 | "unsafe" |
| 6 | 7 | ||
| 7 | "github.com/bisaxa/bitreader" | 8 | "github.com/pektezol/bitreader" |
| 8 | ) | 9 | ) |
| 9 | 10 | ||
| 10 | func CheckError(e error) { | 11 | func CheckError(e error) { |
| @@ -33,6 +34,20 @@ func ReadStringFromFile(file *os.File) string { | |||
| 33 | return output | 34 | return output |
| 34 | } | 35 | } |
| 35 | 36 | ||
| 37 | func ReadStringFromSlice(file []byte) string { | ||
| 38 | var output string | ||
| 39 | reader := bitreader.Reader(bytes.NewReader(file), true) | ||
| 40 | for { | ||
| 41 | value, err := reader.ReadBytes(1) | ||
| 42 | CheckError(err) | ||
| 43 | if value == 0 { | ||
| 44 | break | ||
| 45 | } | ||
| 46 | output += string(rune(value)) | ||
| 47 | } | ||
| 48 | return output | ||
| 49 | } | ||
| 50 | |||
| 36 | func FloatArrFromBytes(byteArr []byte) []float32 { | 51 | func FloatArrFromBytes(byteArr []byte) []float32 { |
| 37 | if len(byteArr) == 0 { | 52 | if len(byteArr) == 0 { |
| 38 | return nil | 53 | return nil |