dkango

package module
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2023 License: MIT Imports: 8 Imported by: 0

README

Dokan bindings for Go

Build Status Go Reference license

This is a Go library to implement a user-mode file system on Windows using Dokan.

Usage

Install Dokan library
winget install dokan-dev.Dokany
API

The only recommended interface is dkango.MountFS(mountPoint, fsys, options). You can add your file system to Windows with a few lines of code.

dokan package provides the low-level API for Dokan, but it is not yet a stable interface. Small breaking changes will be made in the future without any notice.

examples/simple/simple.go

package main

import (
	"os"
	"github.com/binzume/dkango"
)

func main() {
	mount, err := dkango.MountFS("X:", os.DirFS("."), nil)
	if err != nil {
		panic(err)
	}
	defer mount.Close()

	// Block forever
	select {}
}
How to create a writable FS?

See examples/writable/writable.go

go run ./examples/writable testdir R:
type OpenWriterFS interface {
	fs.FS
	OpenWriter(name string, flag int) (io.WriteCloser, error)
}

Other interfaces such as RemoveFS, MkdirFS, RenameFS... are also available.

License

MIT

Documentation

Index

Constants

View Source
const (
	// Enable debug messages
	FlagDebug = dokan.DOKAN_OPTION_DEBUG
	// Output debug messages to stderr
	FlagStderr = dokan.DOKAN_OPTION_STDERR
	// Enable filename:streamname path
	FlagAltStream = dokan.DOKAN_OPTION_ALT_STREAM
	// Readonly FS even if fsys implements OpenWriterFS.
	FlagsWriteProtect = dokan.DOKAN_OPTION_WRITE_PROTECT
	// Network drive
	FlagNetwork = dokan.DOKAN_OPTION_NETWORK
	// Removable drive
	FlagRemovable = dokan.DOKAN_OPTION_REMOVABLE
)

Variables

This section is empty.

Functions

func MountFS

func MountFS(mountPoint string, fsys fs.FS, opt *MountOptions) (*dokan.MountInfo, error)

MountFS mounts fsys on mountPoint.

mountPoint must be a valid unused drive letter or a directory on NTFS.

To provide random access, file opened by fsys should implement io.Seeker or ReaderAt and WriterAt. If only sequential access is provided, many applications will not work properly.

Types

type DiskSpace added in v0.1.4

type DiskSpace struct {
	FreeBytesAvailable     uint64
	TotalNumberOfBytes     uint64
	TotalNumberOfFreeBytes uint64
}

DiskSpace represents the amount of space that is available on a disk. https://docs.microsoft.com/ja-JP/windows/win32/api/fileapi/nf-fileapi-getdiskfreespaceexa

type MkdirFS

type MkdirFS interface {
	fs.FS
	Mkdir(name string, mode fs.FileMode) error
}

An interface to make new directories in the file system.

type MountOptions

type MountOptions struct {
	VolumeInfo    dokan.VolumeInformation
	DiskSpaceFunc func() DiskSpace // optional
	Flags         uint32
}

type OpenDirFS

type OpenDirFS interface {
	fs.FS
	OpenDir(name string) (fs.ReadDirFile, error)
}

An interface for preferentially opening ReadDirFile. If OpenDirFS is not implemented, try using fs.ReadDirFS, then Open file and try using fs.ReadDirFile.

type OpenWriterFS

type OpenWriterFS interface {
	fs.FS
	OpenWriter(name string, flag int) (io.WriteCloser, error)
}

An interface for opening files for writing.

type RemoveFS

type RemoveFS interface {
	fs.FS
	Remove(name string) error
}

An interface to remove file or directory from the file system.

type RenameFS

type RenameFS interface {
	fs.FS
	Rename(name string, newName string) error
}

An interface to rename file or directory from the file system.

type TruncateFS added in v0.1.1

type TruncateFS interface {
	fs.FS
	Truncate(name string, size int64) error
}

An interface to truncate file to specified size. If TruncateFS is not implemented, open file and try using file.Truncate(size).

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL