Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram. If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

local.go 522B

123456789101112131415161718192021222324252627282930
  1. package files
  2. import (
  3. "context"
  4. "fmt"
  5. "io"
  6. "os"
  7. )
  8. type localFile struct {
  9. path string
  10. }
  11. func (l localFile) Open(ctx context.Context) (io.ReadCloser, error) {
  12. return os.Open(l.path) // nolint: wrapcheck
  13. }
  14. func (l localFile) String() string {
  15. return l.path
  16. }
  17. func NewLocal(path string) (File, error) {
  18. if stat, err := os.Stat(path); os.IsNotExist(err) || stat.IsDir() || stat.Mode().Perm()&0o400 == 0 {
  19. return nil, fmt.Errorf("%s is not a readable file", path)
  20. }
  21. return localFile{
  22. path: path,
  23. }, nil
  24. }