afp

package
v1.47.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DSICloseSession                    = byte(0x1)
	DSICommand                         = byte(0x2)
	DSIGetStatus                       = byte(0x3)
	DSIOpenSession                     = byte(0x4)
	DSITickle                          = byte(0x5)
	DSIWrite                           = byte(0x6)
	DSIAttention                       = byte(0x8)
	AFPByteLock                        = 0x01
	AFPCloseVol                        = 0x02
	AFPCloseDir                        = 0x03
	AFPCloseFork                       = 0x04
	AFPCopyFile                        = 0x05
	AFPCreateDir                       = 0x06
	AFPCreateFile                      = 0x07
	AFPDelete                          = 0x08
	AFPEnumerate                       = 0x09
	AFPFlush                           = 0x0a
	AFPFlushFork                       = 0x0b
	AFPGetForkParams                   = 0x0e
	AFPGetSrvrInfo                     = 0x0f
	AFPGetSrvrParams                   = 0x10
	AFPGetVolParams                    = 0x11
	AFPLogin                           = 0x12
	AFPLoginCont                       = 0x13
	AFPLogout                          = 0x14
	AFPMapID                           = 0x15
	AFPMapName                         = 0x16
	AFPMoveAndRename                   = 0x17
	AFPOpenVol                         = 0x18
	AFPOpenDir                         = 0x19
	AFPOpenFork                        = 0x1a
	AFPRead                            = 0x1b
	AFPRename                          = 0x1c
	AFPSetDirParams                    = 0x1d
	AFPSetFileParams                   = 0x1e
	AFPSetForkParams                   = 0x1f
	AFPSetVolParams                    = 0x20
	AFPWrite                           = 0x21
	AFPGetFileDirParams                = 0x22
	AFPSetFileDirParams                = 0x23
	AFPChangePW                        = 0x24
	AFPGetUserInfo                     = 0x25
	AFPGetSrvrMesg                     = 0x26
	AFPCreateID                        = 0x27
	AFPDeleteID                        = 0x28
	AFPResolveID                       = 0x29
	AFPExchangeFiles                   = 0x2a
	AFPCatSearch                       = 0x2b
	AFPOpenDT                          = 0x30
	AFPCloseDT                         = 0x31
	AFPGetIcon                         = 0x33
	AFPGetIconInfo                     = 0x34
	AFPAddAppl                         = 0x35
	AFPRmvAppl                         = 0x36
	AFPGetAppl                         = 0x37
	AFPAddComment                      = 0x38
	AFPRmvComment                      = 0x39
	AFPGetComment                      = 0x3a
	AFPReadExt                         = 0x3c
	AFPWriteExt                        = 0x3d
	AFPGetExtAttr                      = 0x45
	AFPSetExtAttr                      = 0x46
	VolBitmapAttributes                = 0x1
	VolBitmapSignature                 = 0x2
	VolBitmapCreationDate              = 0x4
	VolBitmapModificationDate          = 0x8
	VolBitmapBackupDate                = 0x10
	VolBitmapID                        = 0x20
	VolBitmapBytesFree                 = 0x40
	VolBitmapBytesTotal                = 0x80
	VolBitmapName                      = 0x100
	VolBitmapExtendedBytesFree         = 0x200
	VolBitmapExtendedBytesTotal        = 0x400
	VolBitmapBlockSize                 = 0x800
	FileBitmapAttributes               = 0x1
	FileBitmapParentDirID              = 0x2
	FileBitmapCreationDate             = 0x4
	FileBitmapModificationDate         = 0x8
	FileBitmapBackupDate               = 0x10
	FileBitmapFinderInfo               = 0x20
	FileBitmapLongName                 = 0x40
	FileBitmapShortName                = 0x80
	FileBitmapNodeID                   = 0x100
	FileBitmapDataForkSize             = 0x200
	FileBitmapResourceForkSize         = 0x400
	FileBitmapExtendedDataForkSize     = 0x800
	FileBitmapLaunchLimit              = 0x1000
	FileBitmapUTF8Name                 = 0x2000
	FileBitmapExtendedResourceForkSize = 0x4000
	FileBitmapUnixPrivileges           = 0x8000
	FileBitmapALL                      = 0xFFFF
	DirBitmapAttributes                = 0x1
	DirBitmapParentDirID               = 0x0
	DirBitmapCreationDate              = 0x4
	DirBitmapModificationDate          = 0x8
	DirBitmapBackupDate                = 0x10
	DirBitmapFinderInfo                = 0x20
	DirBitmapLongName                  = 0x40
	DirBitmapShortName                 = 0x80
	DirBitmapNodeID                    = 0x100
	DirBitmapOffspringCount            = 0x200
	DirBitmapOwnerID                   = 0x400
	DirBitmapGroupID                   = 0x800
	DirBitmapAccessRights              = 0x1000
	DirBitmapUTF8Name                  = 0x2000
	DirBitmapUnixPrivileges            = 0x8000
	DirBitmapALL                       = 0xBFFF
	AccessModeRead                     = 0x1
	AccessModeWrite                    = 0x2
	AccessModeDenyRead                 = 0x10
	AccessModeDenyWrite                = 0x20
)

Variables

This section is empty.

Functions

func AddAppl added in v1.39.0

func AddAppl(conn net.Conn, volID uint16, dirID uint32, creator [4]byte, applTag [4]byte, path string) bool

Sends the AddAppl command to the AFP server.

func AnonymousLogin

func AnonymousLogin(conn net.Conn) bool

Logs into the AFP server as the guest user.

func CloseFork

func CloseFork(conn net.Conn, forkID uint16) bool

Sends the CloseFork command to the AFP server.

func Connect

func Connect(host string, port int, ssl bool) (net.Conn, bool)

Connects to an AFP server and opens a session.

func CreateFile

func CreateFile(conn net.Conn, volumeID uint16, dirID uint32, fileName string) bool

Sends the CreateFile command to the AFP server.

func Delete

func Delete(conn net.Conn, volumeID uint16, dirID uint32, path string) bool

Sends the Delete command to the AFP server.

func DeleteFile

func DeleteFile(conn net.Conn, path string) bool

Deletes a file from the root directory of AFP Server via filename.

func Disconnect

func Disconnect(conn net.Conn) bool

Disconnects from an active AFP session.

func FlushFork

func FlushFork(conn net.Conn, forkID uint16) bool

Sends the FlushFork command to the AFP server.

func Logout

func Logout(conn net.Conn) bool

Sends the Logout command to the AFP server.

func MoveAndRenameFile

func MoveAndRenameFile(conn net.Conn, srcVolID uint16, srcDirID uint32, srcPath string, dstDirID uint32, dstPath string, dstName string) bool

Sends the Move and Rename command to the AFP server.

func OpenSession

func OpenSession(conn net.Conn) bool

Creates an AFP session.

func OpenVolume

func OpenVolume(conn net.Conn, bitmap uint16, volumeName []byte) (uint16, bool)

Sends the OpenVolume command to the AFP server.

func ReadFile

func ReadFile(conn net.Conn, path string, forkFlag byte) ([]byte, bool)

Reads a file in the root directory on a AFP server. Works by looking up the file in the root volume, opening it's metadata file, and reading the file data. The parameters are conn - a connection to the AFP server created by afp.Connect(), path - a string of the file to open, and forkFlag, which is passed to OpenFork. To read just the file contents, it should be 0x00, to read fork resource data, it should be 0x02.

func RenameFileHelper

func RenameFileHelper(conn net.Conn, srcPath string, dstPath string, dstName string) bool

Move and Renames an existing file to the root directory of AFP Server.

func SetFilParams added in v1.39.0

func SetFilParams(conn net.Conn, volID uint16, dirID uint32, bitmap uint16, path string, buffer []byte) bool

Sends the setfileparams command to the AFP server.

func SetForkParams

func SetForkParams(conn net.Conn, forkID uint16, bitmap uint16, size uint64) bool

Sends the SetForkParams command to the AFP server.

func WalkRootDir

func WalkRootDir(conn net.Conn, path string) (uint16, uint32, bool)

Walks the root directory of a volume by opening the volume by ID.

func WriteExt

func WriteExt(conn net.Conn, forkID uint16, fdata []byte) bool

Sends the WriteExt command to the AFP server.

func WriteFile

func WriteFile(conn net.Conn, path string, fdata []byte, withFork bool) bool

Writes to an existing file to the root directory of AFP Server. The parameters are conn - a connection to the AFP server created by afp.Connect(), path - a string of the file to create, fdata - the file data to write, and withFork - whether to create a fork metadata file.

func WriteNewFile

func WriteNewFile(conn net.Conn, path string, fdata []byte, withFork bool) bool

Writes a new file to the root directory of AFP Server. The parameters are conn - a connection to the AFP server created by afp.Connect(), path - a string of the file to create, fdata - the file data to write, and withFork - whether to create a fork metadata file.

func WritePacket

func WritePacket(conn net.Conn, packet FPPacket) bool

Converts FPPacket to bytes and sends them.

Types

type FPPacket

type FPPacket struct {
	Header Header
	Body   []byte
}

func CreateFPPacket

func CreateFPPacket(command byte, payload []byte) FPPacket

Creates a FPPacket given a command byte and payload.

func Decode

func Decode(data []byte) (FPPacket, bool)

Decode bytes into an FPPacket.

func GetAppl added in v1.39.0

func GetAppl(conn net.Conn, volID uint16, creator [4]byte, aIndex uint16, bitmap uint16) (*FPPacket, bool)

Sends the GetAppl command to the AFP server.

func GetForkParams

func GetForkParams(conn net.Conn, forkID uint16, bitmap uint16) (*FPPacket, bool)

Sends the GetForkParams command to the AFP server.

func GetServerStatus

func GetServerStatus(host string, port int, ssl bool) (*FPPacket, bool)

Connects to an AFP server and gets server information.

func OpenFork

func OpenFork(conn net.Conn, flag byte, volumeID uint16, dirID uint32, bitmap uint16, accessMode uint16, path string) (*FPPacket, bool)

Sends the OpenFork command to the AFP server.

func ReadExt

func ReadExt(conn net.Conn, forkID uint16, offset uint64, count uint64) (*FPPacket, bool)

Sends the ReadExt command to the AFP server.

func ReadPacket

func ReadPacket(conn net.Conn) (*FPPacket, bool)

Reads bytes from connection and converts them to an FPPacket.

type Header struct {
	Flags           uint8
	Command         uint8
	RequestID       uint16
	ErrorCode       uint32
	TotalDataLength uint32
	Reserved        uint32
}

func (*Header) Encode

func (d *Header) Encode() []byte

encode an FPPacket to bytes.

Jump to

Keyboard shortcuts

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