You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2023/08/02 10:20:19 UTC

[skywalking-banyandb] branch main updated: Define file system operation interface (#306)

This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git


The following commit(s) were added to refs/heads/main by this push:
     new 20ce7d64 Define file system operation interface (#306)
20ce7d64 is described below

commit 20ce7d64e12d5f67948d40f4459bb4502b41ebd9
Author: HHoflittlefish777 <77...@users.noreply.github.com>
AuthorDate: Wed Aug 2 18:20:15 2023 +0800

    Define file system operation interface (#306)
    
    
    
    ---------
    
    Co-authored-by: Gao Hongtao <ha...@gmail.com>
---
 pkg/fs/file_system.go | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/pkg/fs/file_system.go b/pkg/fs/file_system.go
new file mode 100644
index 00000000..eb61eecc
--- /dev/null
+++ b/pkg/fs/file_system.go
@@ -0,0 +1,73 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// Package fs (file system) is an independent component to operate file and directory.
+package fs
+
+import (
+	"container/list"
+)
+
+// Mode contains permission of file and directory.
+type Mode struct{}
+
+// Iter is used for streaming read.
+type Iter struct{}
+
+// Dir operation interface.
+type Dir interface {
+	// Delete the directory.
+	DeleteDirectory() error
+	// Rename the directory.
+	RenameDirectory(newName string) error
+	// Get all lists of files or children's directories in the directory.
+	ReadDirectory() (list.List, error)
+	// Set directory permission.
+	SetDirectoryPermission(permission Mode) error
+}
+
+// File operation interface.
+type File interface {
+	// Append mode, which adds new data to the end of a file.
+	AppendWriteFile(buffer []byte) error
+	// Delete the file.
+	DeleteFile() error
+	// Reading a specified location of file.
+	ReadFile(offset int, buffer []byte) error
+	// Read the entire file using streaming read
+	StreamReadFile(offset int, buffer []byte) (*Iter, error)
+	// Rename the file.
+	RenameFile(newName string) error
+	// Get the file written data's size and return an error if the file does not exist. The unit of file size is Byte.
+	GetFileSize() (int, error)
+	// Set directory permission.
+	SetFilePermission(permission Mode) error
+}
+
+// FileSystem operation interface.
+type FileSystem interface {
+	// Create the directory by specified name and mode.
+	CreateDirectory(name string, permission Mode) error
+	// Open the directory by specified name.
+	OpenDirectory(name string) (*Dir, error)
+	// Create the file by specified name and mode.
+	CreateFile(name string, permission Mode) error
+	// Open the file by specified name.
+	OpenFile(name string) (*File, error)
+	// Flush mode, which flushes all data to one file.
+	FlushWriteFile(buffer []byte, permission Mode) (*File, error)
+}