Documentation ¶
Index ¶
- Constants
- func AbsWithSlash(path string) (string, error)
- func CBZInfo(path string) (int, string, error)
- func CopyFile(source string, dest string) error
- func CopyImage(relSource string, relDest string) (string, error)
- func FetchImage(url string) (string, string, error)
- func Get(url string) ([]byte, error)
- func GetImagePath(relpath string) string
- func GetWithCache(url string) ([]byte, error)
- func IsDir(path string) bool
- func IsPrefixPath(target string, prefix string) (bool, error)
- func Max[T constraints.Ordered](a T, b T) T
- func Min[T constraints.Ordered](a T, b T) T
- func PathExists(path string) bool
- func PoolMap[T any, R any](values []T, consumer PoolConsumer[T, R]) ([]R, error)
- func ToJSON(data any) (string, error)
- func UnsafeJoin(values []string) string
- func UnsafeSplit(text string) []string
- func WriteImage(data []byte, relpath string) error
- func ZipExtractFile(zipPath string, filename string) ([]byte, error)
- func ZipImageCount(path string) (int, error)
- func ZipListFilenames(path string) ([]string, error)
- type ParallelPool
- type PoolConsumer
Constants ¶
const CACHE_DIRNAME string = "cache"
const IMAGE_DIRNAME string = "images"
const MIN_CHAN_SIZE = 256
const RATE_LIMIT_DELAY_SEC = 2
Do not query a single site too quickly.
const UNSAFE_JOIN_DELIM = "\u2012"
A figure dash ("‒").
const UNSAFE_JOIN_REPLACE_CHAR = "-"
A hyphen (dash).
Variables ¶
This section is empty.
Functions ¶
func AbsWithSlash ¶
Call filepath.Abs(), but add a trailing slash for dirs. Checking for a dir requires a stat and implies the existance of the dirent.
func CBZInfo ¶
Assume that the archive is a CBZ, and get the number of imaeges and the first image (as a thumbnail).
func FetchImage ¶
Returns (abspath, relpath, error).
func GetImagePath ¶
func GetWithCache ¶
func IsPrefixPath ¶
Is |prefix| a prefix of |target|. (Same paths counts as a prefix.)
func Max ¶
func Max[T constraints.Ordered](a T, b T) T
func Min ¶
func Min[T constraints.Ordered](a T, b T) T
func UnsafeJoin ¶
Join together strings by first replacing any instances of UNSAFE_JOIN_DELIM with UNSAFE_JOIN_REPLACE_CHAR, and then joining the strings together with UNSAFE_JOIN_DELIM. This could mean that UnsafeSplit(UnsafeJoin(values)) != values. However, we will use a delimiter that is rare and typically represented visually the same as the replacement character.
func UnsafeSplit ¶
func WriteImage ¶
func ZipImageCount ¶
Count the number of image files in a zip archive.
func ZipListFilenames ¶
Types ¶
type ParallelPool ¶
A pool should only be accessed from a single thread.
func NewParallelPool ¶
func NewParallelPool[T any, R any](consumer PoolConsumer[T, R]) *ParallelPool[T, R]
func NewParallelPoolWithSize ¶
func NewParallelPoolWithSize[T any, R any](numValues int, consumer PoolConsumer[T, R]) *ParallelPool[T, R]
func (*ParallelPool[T, R]) AddWork ¶
func (this *ParallelPool[T, R]) AddWork(value T)
Will panic if ParallelPool.NoMoreWork() is called first. Should be called on the same thread as NoMoreWork.
func (*ParallelPool[T, R]) Close ¶
func (this *ParallelPool[T, R]) Close()
func (*ParallelPool[T, R]) GetResult ¶
func (this *ParallelPool[T, R]) GetResult() (R, bool, error)
The returned boolean will be false when the output channel has been closed and there is no work work on it (i.e., all work is consumed).
func (*ParallelPool[T, R]) NoMoreWork ¶
func (this *ParallelPool[T, R]) NoMoreWork()
Should be called on the same thread as AddWork.