mirror of
https://github.com/tailscale/tailscale.git
synced 2026-12-06 23:36:34 +09:00
In PR #22749 we attempteed to clear up the casting needed for the fileOps for the close action by using the io.Closer interface. This broke the dependency to our android repo. This change both removes this interface change that breaks compatability, and also removes the closeOps field. After further review this field was no longer necessary after we removed the persistent root behavior. Updates tailscale/corp#51118 Change-Id: I1870030f130e92950843afb8c306b32f2008fca4 Signed-off-by: Mike Jensen <mikej@tailscale.com>
42 lines
1.4 KiB
Go
42 lines
1.4 KiB
Go
// Copyright (c) Tailscale Inc & contributors
|
||
// SPDX-License-Identifier: BSD-3-Clause
|
||
|
||
package taildrop
|
||
|
||
import (
|
||
"io"
|
||
"io/fs"
|
||
"os"
|
||
)
|
||
|
||
// FileOps abstracts over both local‐FS paths and Android SAF URIs.
|
||
type FileOps interface {
|
||
// OpenWriter creates or truncates a file named relative to the receiver's root,
|
||
// seeking to the specified offset. If the file does not exist, it is created with mode perm
|
||
// on platforms that support it.
|
||
//
|
||
// It returns an [io.WriteCloser] and the file's absolute path, or an error.
|
||
// This call may block. Callers should avoid holding locks when calling OpenWriter.
|
||
OpenWriter(name string, offset int64, perm os.FileMode) (wc io.WriteCloser, path string, err error)
|
||
|
||
// Remove deletes a file or directory relative to the receiver's root.
|
||
// It returns [io.ErrNotExist] if the file or directory does not exist.
|
||
Remove(name string) error
|
||
|
||
// Rename atomically renames oldPath to a new file named newName,
|
||
// returning the full new path or an error.
|
||
Rename(oldPath, newName string) (newPath string, err error)
|
||
|
||
// ListFiles returns just the basenames of all regular files
|
||
// in the root directory.
|
||
ListFiles() ([]string, error)
|
||
|
||
// Stat returns the FileInfo for the given name or an error.
|
||
Stat(name string) (fs.FileInfo, error)
|
||
|
||
// OpenReader opens the given basename for the given name or an error.
|
||
OpenReader(name string) (io.ReadCloser, error)
|
||
}
|
||
|
||
var newFileOps func(dir string) (FileOps, error)
|