mirror of
https://github.com/larksuite/cli.git
synced 2026-07-03 14:02:43 +08:00
* feat: add FileIO extension for file transfer abstraction Introduce extension/fileio package with Provider/FileIO/File interfaces and a global registry, following the same pattern as extension/credential. - Add LocalFileIO default implementation with path validation and atomic writes - Wire FileIOProvider into Factory and resolve at runtime via RuntimeContext.FileIO() - Factory holds Provider (not resolved instance), deferring resolution to execution time
24 lines
667 B
Go
24 lines
667 B
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package validate
|
|
|
|
import (
|
|
"io"
|
|
"os"
|
|
|
|
"github.com/larksuite/cli/internal/vfs/localfileio"
|
|
)
|
|
|
|
// AtomicWrite writes data to path atomically.
|
|
// Delegates to localfileio.AtomicWrite.
|
|
func AtomicWrite(path string, data []byte, perm os.FileMode) error {
|
|
return localfileio.AtomicWrite(path, data, perm)
|
|
}
|
|
|
|
// AtomicWriteFromReader atomically copies reader contents into path.
|
|
// Delegates to localfileio.AtomicWriteFromReader.
|
|
func AtomicWriteFromReader(path string, reader io.Reader, perm os.FileMode) (int64, error) {
|
|
return localfileio.AtomicWriteFromReader(path, reader, perm)
|
|
}
|