mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[chore] add back exif-terminator and use only for jpeg,png,webp (#3161)
* add back exif-terminator and use only for jpeg,png,webp * fix arguments passed to terminateExif() * pull in latest exif-terminator * fix test * update processed img --------- Co-authored-by: tobi <tobi.smethurst@protonmail.com>
This commit is contained in:
52
vendor/github.com/dsoprea/go-utility/v2/filesystem/calculate_seek.go
generated
vendored
Normal file
52
vendor/github.com/dsoprea/go-utility/v2/filesystem/calculate_seek.go
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
package rifs
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/dsoprea/go-logging"
|
||||
)
|
||||
|
||||
// SeekType is a convenience type to associate the different seek-types with
|
||||
// printable descriptions.
|
||||
type SeekType int
|
||||
|
||||
// String returns a descriptive string.
|
||||
func (n SeekType) String() string {
|
||||
if n == io.SeekCurrent {
|
||||
return "SEEK-CURRENT"
|
||||
} else if n == io.SeekEnd {
|
||||
return "SEEK-END"
|
||||
} else if n == io.SeekStart {
|
||||
return "SEEK-START"
|
||||
}
|
||||
|
||||
log.Panicf("unknown seek-type: (%d)", n)
|
||||
return ""
|
||||
}
|
||||
|
||||
// CalculateSeek calculates an offset in a file-stream given the parameters.
|
||||
func CalculateSeek(currentOffset int64, delta int64, whence int, fileSize int64) (finalOffset int64, err error) {
|
||||
defer func() {
|
||||
if state := recover(); state != nil {
|
||||
err = log.Wrap(state.(error))
|
||||
finalOffset = 0
|
||||
}
|
||||
}()
|
||||
|
||||
if whence == os.SEEK_SET {
|
||||
finalOffset = delta
|
||||
} else if whence == os.SEEK_CUR {
|
||||
finalOffset = currentOffset + delta
|
||||
} else if whence == os.SEEK_END {
|
||||
finalOffset = fileSize + delta
|
||||
} else {
|
||||
log.Panicf("whence not valid: (%d)", whence)
|
||||
}
|
||||
|
||||
if finalOffset < 0 {
|
||||
finalOffset = 0
|
||||
}
|
||||
|
||||
return finalOffset, nil
|
||||
}
|
Reference in New Issue
Block a user