mirror of
https://github.com/ceph/go-ceph
synced 2024-12-22 14:13:21 +00:00
bbf5fecf90
Continue organizing the cephfs functionality by creating new files for the most basic path management functions: MakeDir, RemoveDir, ChangeDir, CurrentDir Similarly, the dedicated test functions for those items are moved into a new file as well. Signed-off-by: John Mulligan <jmulligan@redhat.com>
47 lines
1.0 KiB
Go
47 lines
1.0 KiB
Go
package cephfs
|
|
|
|
/*
|
|
#cgo LDFLAGS: -lcephfs
|
|
#cgo CPPFLAGS: -D_FILE_OFFSET_BITS=64
|
|
#include <stdlib.h>
|
|
#include <cephfs/libcephfs.h>
|
|
*/
|
|
import "C"
|
|
|
|
import (
|
|
"unsafe"
|
|
)
|
|
|
|
// CurrentDir gets the current working directory.
|
|
func (mount *MountInfo) CurrentDir() string {
|
|
cDir := C.ceph_getcwd(mount.mount)
|
|
return C.GoString(cDir)
|
|
}
|
|
|
|
// ChangeDir changes the current working directory.
|
|
func (mount *MountInfo) ChangeDir(path string) error {
|
|
cPath := C.CString(path)
|
|
defer C.free(unsafe.Pointer(cPath))
|
|
|
|
ret := C.ceph_chdir(mount.mount, cPath)
|
|
return getError(ret)
|
|
}
|
|
|
|
// MakeDir creates a directory.
|
|
func (mount *MountInfo) MakeDir(path string, mode uint32) error {
|
|
cPath := C.CString(path)
|
|
defer C.free(unsafe.Pointer(cPath))
|
|
|
|
ret := C.ceph_mkdir(mount.mount, cPath, C.mode_t(mode))
|
|
return getError(ret)
|
|
}
|
|
|
|
// RemoveDir removes a directory.
|
|
func (mount *MountInfo) RemoveDir(path string) error {
|
|
cPath := C.CString(path)
|
|
defer C.free(unsafe.Pointer(cPath))
|
|
|
|
ret := C.ceph_rmdir(mount.mount, cPath)
|
|
return getError(ret)
|
|
}
|