ejectcd

package module
v0.0.0-...-62cf486 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2020 License: MIT Imports: 5 Imported by: 0

README

ejectcd

Eject CD/DVD tray from golang. and check the status of CD/DVD tray. Only for windows.

How to use

$ go get gitlab.com/shigeya53/ejectcd
import "log"
import "gitlab.com/shigeya53/ejectcd"

func main() {
    // first argument is Drive letter, second arugment is timeout in millisec
    err := ejectcd.EjectDrive("E", 1000)
    if err != nil {
        log.Fatal(err)
    }

    // r == 0, tray closed
    // r == 1, tray open
    // r == 2, tray closed, media present
    r, err := ejectcd.DriveStatus("E")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(r)
}

Documentation

Rendered for windows/amd64

Index

Constants

View Source
const (
	FSCTL_LOCK_VOLUME           = uint32(0x90018)
	FSCTL_DISMOUNT_VOLUME       = uint32(0x90020)
	IOCTL_STORAGE_MEDIA_REMOVAL = uint32(0x2d4804)
	IOCTL_STORAGE_EJECT_MEDIA   = uint32(0x2d4808)
)
View Source
const IOCTL_SCSI_PASS_THROUGH_DIRECT = 0x4D014
View Source
const MAX_SENSE_LEN = 18
View Source
const SCSI_IOCTL_DATA_IN = 1 // Get data from SCSI device (e.g. for reading)
View Source
const SCSI_IOCTL_DATA_OUT = 0 // Give data to SCSI device (e.g. for writing)
View Source
const SCSI_IOCTL_DATA_UNSPECIFIED = 2 // No data (e.g. for ejecting)

Variables

This section is empty.

Functions

func DriveStatus

func DriveStatus(drive string) (int, error)

func EjectVolume

func EjectVolume(drive string, timeout uint32) error

EjectVolume Eject the tray of the drive with timeout

func GetDriveType

func GetDriveType(lpRootPathName *uint16) (driveType uint32, err error)

func GetTickCount

func GetTickCount() (tick uint32)

Types

type SCSI_PASS_THROUGH_DIRECT

type SCSI_PASS_THROUGH_DIRECT struct {
	Length             uint16
	ScsiStatus         byte
	PathId             byte
	TargetId           byte
	Lun                byte
	CdbLength          byte
	SenseInfoLength    byte
	DataIn             byte
	DataTransferLength uint32
	TimeOutValue       uint32
	DataBuffer         unsafe.Pointer
	SenseInfoOffset    uint32
	Cdb                [16]byte
}

type SCSI_PASS_THROUGH_DIRECT_AND_SENSE_BUFFER

type SCSI_PASS_THROUGH_DIRECT_AND_SENSE_BUFFER struct {
	SenseBuf [MAX_SENSE_LEN]byte
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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