當前位置: 首頁>>代碼示例>>Golang>>正文


Golang C.Vix_GetErrorText函數代碼示例

本文整理匯總了Golang中C.Vix_GetErrorText函數的典型用法代碼示例。如果您正苦於以下問題:Golang Vix_GetErrorText函數的具體用法?Golang Vix_GetErrorText怎麽用?Golang Vix_GetErrorText使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Vix_GetErrorText函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Ls

// Ls lists a directory in the guest operating system.
//
// Parameters:
//
//   dir: The path name of a directory to be listed.
//
// Remarks:
//
//   * Only absolute paths should be used for files in the guest; the resolution
//     of relative paths is not specified.
//
// Since VMware Workstation 6.0
// Minimum Supported Guest OS: Microsoft Windows NT Series, Linux
func (g *Guest) Ls(dir string) ([]*GuestFile, error) {
	var jobHandle C.VixHandle = C.VIX_INVALID_HANDLE
	var err C.VixError = C.VIX_OK
	var files []*GuestFile

	guestdir := C.CString(dir)
	defer C.free(unsafe.Pointer(guestdir))

	jobHandle = C.VixVM_ListDirectoryInGuest(g.handle, guestdir, 0, nil, nil)
	defer C.Vix_ReleaseHandle(jobHandle)

	err = C.vix_job_wait(jobHandle)
	if C.VIX_OK != err {
		return nil, &Error{
			Operation: "guest.Ls.ListDirectoryInGuest",
			Code:      int(err & 0xFFFF),
			Text:      C.GoString(C.Vix_GetErrorText(err, nil)),
		}
	}

	num := C.VixJob_GetNumProperties(jobHandle, C.VIX_PROPERTY_JOB_RESULT_ITEM_NAME)
	for i := 0; i < int(num); i++ {
		var name *C.char
		var size *C.int64
		var modtime *C.int64
		var attrs *C.int

		gfile := &GuestFile{}

		err = C.get_guest_file(jobHandle, C.int(i), name, size, modtime, attrs)
		if C.VIX_OK != err {
			return nil, &Error{
				Operation: "guest.Ls.get_guest_file",
				Code:      int(err & 0xFFFF),
				Text:      C.GoString(C.Vix_GetErrorText(err, nil)),
			}
		}

		gfile.Path = C.GoString(name)
		C.Vix_FreeBuffer(unsafe.Pointer(name))

		gfile.Size = int64(*size)
		gfile.Modtime = int64(*modtime)
		gfile.Attrs = FileAttr(*attrs)

		files = append(files, gfile)
	}

	return files, nil
}
開發者ID:hooklift,項目名稱:govix,代碼行數:63,代碼來源:guest.go

示例2: Mv

// Mv renames a file or directory in the guest operating system.
//
// Parameters:
//
//   path1: The path to the file to be renamed.
//   path2: The path to the new file.
//
// Remarks:
//
//   * Only absolute paths should be used for files in the guest; the resolution
//     of relative paths is not specified.
//
//   * On Windows guests, it fails on directory moves when the destination is on a
//     different volume.
//
//   * Because of the differences in how various operating systems handle
//     filenames, Vix may return either VIX_E_INVALID_ARG or
//     VIX_E_FILE_NAME_TOO_LONG for filenames longer than 255 characters.
//
// Since VMware Workstation 6.0
// Minimum Supported Guest OS: Microsoft Windows NT Series, Linux
func (g *Guest) Mv(path1, path2 string) error {
	var jobHandle C.VixHandle = C.VIX_INVALID_HANDLE
	var err C.VixError = C.VIX_OK

	cpath1 := C.CString(path1)
	cpath2 := C.CString(path2)
	defer C.free(unsafe.Pointer(cpath1))
	defer C.free(unsafe.Pointer(cpath2))

	jobHandle = C.VixVM_RenameFileInGuest(g.handle,
		cpath1,               //oldName
		cpath2,               //newName
		0,                    //options
		C.VIX_INVALID_HANDLE, //propertyListHandle
		nil,                  //callbackProc
		nil)                  //clientData

	defer C.Vix_ReleaseHandle(jobHandle)

	err = C.vix_job_wait(jobHandle)
	if C.VIX_OK != err {
		return &Error{
			Operation: "guest.Mv",
			Code:      int(err & 0xFFFF),
			Text:      C.GoString(C.Vix_GetErrorText(err, nil)),
		}
	}

	return nil
}
開發者ID:hooklift,項目名稱:govix,代碼行數:51,代碼來源:guest.go

示例3: IsFile

// IsFile tests the existence of a file in the guest operating system.
//
// Parameters:
//
//   filepath: The path to the file to be tested.
//
// Remarks:
//
//   * Only absolute paths should be used for files in the guest; the resolution
//     of relative paths is not specified.
//
//   * If filepath exists as a file system object, but is not a normal file (e.g.
//     it is a directory, device, UNIX domain socket, etc),
//     then VIX_OK is returned, and VIX_PROPERTY_JOB_RESULT_GUEST_OBJECT_EXISTS
//     is set to FALSE.
//
// Since VMware Workstation 6.0
// Minimum Supported Guest OS: Microsoft Windows NT Series, Linux
func (g *Guest) IsFile(filepath string) (bool, error) {
	var jobHandle C.VixHandle = C.VIX_INVALID_HANDLE
	var err C.VixError = C.VIX_OK
	var result C.int

	fpath := C.CString(filepath)
	defer C.free(unsafe.Pointer(fpath))

	jobHandle = C.VixVM_FileExistsInGuest(g.handle,
		fpath, // dir path name
		nil,   // callbackProc
		nil)   // clientData

	defer C.Vix_ReleaseHandle(jobHandle)

	err = C.is_file_or_dir(jobHandle, &result)
	if C.VIX_OK != err {
		return false, &Error{
			Operation: "guest.IsFile",
			Code:      int(err & 0xFFFF),
			Text:      C.GoString(C.Vix_GetErrorText(err, nil)),
		}
	}

	if int(result) == C.FALSE {
		return false, nil
	}

	return true, nil
}
開發者ID:hooklift,項目名稱:govix,代碼行數:48,代碼來源:guest.go

示例4: RmFile

// RmFile deletes a file in the guest operating system.
//
// Parameters:
//
//   filepath: file path to be deleted in the guest OS
//
// Remarks:
//   * Only absolute paths should be used for files in the guest; the resolution
//     of relative paths is not specified.
//
// Since VMware Workstation 6.0
// Minimum Supported Guest OS: Microsoft Windows NT Series, Linux
func (g *Guest) RmFile(filepath string) error {
	var jobHandle C.VixHandle = C.VIX_INVALID_HANDLE
	var err C.VixError = C.VIX_OK

	fpath := C.CString(filepath)
	defer C.free(unsafe.Pointer(fpath))

	jobHandle = C.VixVM_DeleteFileInGuest(g.handle,
		fpath, // file path name
		nil,   // callbackProc
		nil)   // clientData

	defer C.Vix_ReleaseHandle(jobHandle)

	err = C.vix_job_wait(jobHandle)
	if C.VIX_OK != err {
		return &Error{
			Operation: "guest.RmFile",
			Code:      int(err & 0xFFFF),
			Text:      C.GoString(C.Vix_GetErrorText(err, nil)),
		}
	}

	return nil
}
開發者ID:hooklift,項目名稱:govix,代碼行數:37,代碼來源:guest.go

示例5: RunScript

// RunScript runs a script in the guest operating system.
//
// Parameters:
//
//   shell: The path to the script interpreter, or NULL to use cmd.exe as
//   the interpreter on Windows.
//
//   script: The text of the script.
//
//   options: Run options for the program. See the remarks below.
//
// Remarks:
//
//   * This function runs the script in the guest operating system.
//
//   * The current working directory for the script executed in the guest is
//     not defined. Absolute paths should be used for files in the guest,
//     including the path to the shell or interpreter, and any files referenced
//     in the script text.
//
//   * If the options parameter is RUNPROGRAM_WAIT, this function will block and
//     return only when the program exits in the guest operating system.
//     Alternatively, you can pass RUNPROGRAM_RETURN_IMMEDIATELY as the value of
//     the options parameter, and this makes the function to return as soon as the
//     program starts in the guest.
//
//   * The following properties will be returned:
//     PROCESS_ID: the process id; however, if the guest has an older version of
//                 Tools (those released with Workstation 6 and earlier) and
//                 the RUNPROGRAM_RETURN_IMMEDIATELY flag is used, then the
//                 process ID will not be returned from the guest and this
//                 property will return 0.
//     ELAPSED_TIME: the process elapsed time;
//     PROGRAM_EXIT_CODE: the process exit code.
//
//   * If the option parameter is RUNPROGRAM_RETURN_IMMEDIATELY, the latter two
//     will both be 0.
//
//   * Depending on the behavior of the guest operating system, there may be a
//     short delay after the function returns before the process is visible in the
//     guest operating system.
//
//   * If the total size of the specified interpreter and the script text is
//     larger than 60536 bytes, then the error VIX_E_ARGUMENT_TOO_BIG is returned.
//
// Since VMware Workstation 6.0
// Minimum Supported Guest OS: Microsoft Windows NT Series, Linux
func (g *Guest) RunScript(shell, args string, options RunProgramOption) (uint64, int, int, error) {
	var jobHandle C.VixHandle = C.VIX_INVALID_HANDLE
	var err C.VixError = C.VIX_OK
	var pid *C.uint64
	var elapsedtime *C.int
	var exitCode *C.int

	cshell := C.CString(shell)
	cargs := C.CString(args)
	defer C.free(unsafe.Pointer(cshell))
	defer C.free(unsafe.Pointer(cargs))

	jobHandle = C.VixVM_RunProgramInGuest(g.handle,
		cshell, //guestProgramName
		cargs,  //commandLineArgs
		C.VixRunProgramOptions(options), //options
		C.VIX_INVALID_HANDLE,            //propertyListHandle
		nil,                             // callbackProc
		nil)                             // clientData

	defer C.Vix_ReleaseHandle(jobHandle)

	err = C.get_program_output(jobHandle, pid, elapsedtime, exitCode)

	if C.VIX_OK != err {
		return 0, 0, 0, &Error{
			Operation: "guest.RunScript.get_program_output",
			Code:      int(err & 0xFFFF),
			Text:      C.GoString(C.Vix_GetErrorText(err, nil)),
		}
	}

	return uint64(*pid), int(*elapsedtime), int(*exitCode), nil
}
開發者ID:hooklift,項目名稱:govix,代碼行數:81,代碼來源:guest.go

示例6: FileInfo

// FileInfo returns information about a file in the guest operating system.
//
// Parameters:
//
//   filepath: The path name of the file in the guest.
//
// Remarks:
//   * Only absolute paths should be used for files in the guest;
//     the resolution of relative paths is not specified.
//
// Since VMware Workstation 6.5
// Minimum Supported Guest OS: Microsoft Windows NT Series, Linux
func (g *Guest) FileInfo(filepath string) (*GuestFile, error) {
	var jobHandle C.VixHandle = C.VIX_INVALID_HANDLE
	var err C.VixError = C.VIX_OK
	var fsize *C.int64
	var flags *C.int
	var modtime *C.int64

	fpath := C.CString(filepath)
	defer C.free(unsafe.Pointer(fpath))

	jobHandle = C.VixVM_GetFileInfoInGuest(g.handle,
		fpath, // file path name
		nil,   // callbackProc
		nil)   // clientData

	defer C.Vix_ReleaseHandle(jobHandle)

	err = C.get_file_info(jobHandle, fsize, flags, modtime)
	if C.VIX_OK != err {
		return nil, &Error{
			Operation: "guest.FileInfo",
			Code:      int(err & 0xFFFF),
			Text:      C.GoString(C.Vix_GetErrorText(err, nil)),
		}
	}

	return &GuestFile{
		Path:    filepath,
		Size:    int64(*fsize),
		Attrs:   FileAttr(*flags),
		Modtime: int64(*modtime),
	}, nil
}
開發者ID:hooklift,項目名稱:govix,代碼行數:45,代碼來源:guest.go

示例7: CopyFileToHost

// CopyFileToHost copies a file or directory from the guest operating system to the local
// system (where the VIX client is running).
//
// Parameters:
//
//   guestpath: The path name of a file on a file system available to the guest.
//   hostpath: The path name of a file on a file system available to the Vix
//   client.
//
func (g *Guest) CopyFileToHost(guestpath, hostpath string) error {
	var jobHandle C.VixHandle = C.VIX_INVALID_HANDLE
	var err C.VixError = C.VIX_OK

	gpath := C.CString(guestpath)
	hpath := C.CString(hostpath)
	defer C.free(unsafe.Pointer(gpath))
	defer C.free(unsafe.Pointer(hpath))

	jobHandle = C.VixVM_CopyFileFromGuestToHost(g.handle,
		gpath,                // src name
		hpath,                // dest name
		0,                    // options
		C.VIX_INVALID_HANDLE, // propertyListHandle
		nil,                  // callbackProc
		nil)                  // clientData

	defer C.Vix_ReleaseHandle(jobHandle)

	err = C.vix_job_wait(jobHandle)
	if C.VIX_OK != err {
		return &Error{
			Operation: "guest.CopyFileToHost",
			Code:      int(err & 0xFFFF),
			Text:      C.GoString(C.Vix_GetErrorText(err, nil)),
		}
	}

	return nil
}
開發者ID:hooklift,項目名稱:govix,代碼行數:39,代碼來源:guest.go

示例8: MkTemp

// MkTemp creates a temporary file in the guest operating system.
// The user is responsible for removing the file when it is no longer needed.
//
// Since VMware Workstation 6.0
// Minimum Supported Guest OS: Microsoft Windows NT Series, Linux
func (g *Guest) MkTemp() (string, error) {
	var jobHandle C.VixHandle = C.VIX_INVALID_HANDLE
	var err C.VixError = C.VIX_OK
	var tempFilePath *C.char

	jobHandle = C.VixVM_CreateTempFileInGuest(g.handle,
		0,                    // options
		C.VIX_INVALID_HANDLE, // propertyListHandle
		nil,                  // callbackProc
		nil)                  // clientData

	defer C.Vix_ReleaseHandle(jobHandle)

	err = C.get_temp_filepath(jobHandle, tempFilePath)
	defer C.Vix_FreeBuffer(unsafe.Pointer(tempFilePath))

	if C.VIX_OK != err {
		return "", &Error{
			Operation: "guest.MkTemp",
			Code:      int(err & 0xFFFF),
			Text:      C.GoString(C.Vix_GetErrorText(err, nil)),
		}
	}

	return C.GoString(tempFilePath), nil
}
開發者ID:hooklift,項目名稱:govix,代碼行數:31,代碼來源:guest.go

示例9: MkDir

// MkDir creates a directory in the guest operating system.
//
// Parameters:
//
//   path: Directory path to be created in the guest OS
//
// Remarks:
//
//   * If the parent directories for the specified path do not exist, this
//     function will create them.
//
//   * If the directory already exists, the error will be set to
//     VIX_E_FILE_ALREADY_EXISTS.
//
//   * Only absolute paths should be used for files in the guest; the resolution
//     of relative paths is not specified.
//
// Since Workstation 6.0
// Minimum Supported Guest OS: Microsoft Windows NT Series, Linux
func (g *Guest) MkDir(path string) error {
	var jobHandle C.VixHandle = C.VIX_INVALID_HANDLE
	var err C.VixError = C.VIX_OK

	cpath := C.CString(path)
	defer C.free(unsafe.Pointer(cpath))

	jobHandle = C.VixVM_CreateDirectoryInGuest(g.handle,
		cpath,                // path name
		C.VIX_INVALID_HANDLE, // propertyListHandle
		nil,                  // callbackProc
		nil)                  // clientData

	defer C.Vix_ReleaseHandle(jobHandle)

	err = C.vix_job_wait(jobHandle)
	if C.VIX_OK != err {
		return &Error{
			Operation: "guest.MkDir",
			Code:      int(err & 0xFFFF),
			Text:      C.GoString(C.Vix_GetErrorText(err, nil)),
		}
	}

	return nil
}
開發者ID:hooklift,項目名稱:govix,代碼行數:45,代碼來源:guest.go

示例10: NumChildren

// NumChildren returns the number of child snapshots of a specified snapshot.
//
// Remarks:
//
//   * This function is not supported when using the VMWARE_PLAYER provider.
//
// Since VMware Workstation 6.0.
func (s *Snapshot) NumChildren() (int, error) {
	var err C.VixError = C.VIX_OK
	var numChildren *C.int

	err = C.VixSnapshot_GetNumChildren(s.handle, numChildren)

	if C.VIX_OK != err {
		return 0, &Error{
			Operation: "snapshot.NumChildren",
			Code:      int(err & 0xFFFF),
			Text:      C.GoString(C.Vix_GetErrorText(err, nil)),
		}
	}

	return int(*numChildren), nil
}
開發者ID:hooklift,項目名稱:govix,代碼行數:23,代碼來源:snapshot.go

示例11: Name

// Name returns user defined name for the snapshot.
func (s *Snapshot) Name() (string, error) {
	var err C.VixError = C.VIX_OK
	var name *C.char

	err = C.get_property(s.handle,
		C.VIX_PROPERTY_SNAPSHOT_DISPLAYNAME,
		unsafe.Pointer(&name))

	defer C.Vix_FreeBuffer(unsafe.Pointer(name))

	if C.VIX_OK != err {
		return "", &Error{
			Operation: "snapshot.Name",
			Code:      int(err & 0xFFFF),
			Text:      C.GoString(C.Vix_GetErrorText(err, nil)),
		}
	}

	return C.GoString(name), nil
}
開發者ID:hooklift,項目名稱:govix,代碼行數:21,代碼來源:snapshot.go

示例12: SharedFoldersParentDir

// SharedFoldersParentDir returns the parent dir for share folders in the Guest.
func (g *Guest) SharedFoldersParentDir() (string, error) {
	var err C.VixError = C.VIX_OK
	var path *C.char

	err = C.get_property(g.handle,
		C.VIX_PROPERTY_GUEST_SHAREDFOLDERS_SHARES_PATH,
		unsafe.Pointer(&path))

	defer C.Vix_FreeBuffer(unsafe.Pointer(path))

	if C.VIX_OK != err {
		return "", &Error{
			Operation: "guest.SharedFoldersParentDir",
			Code:      int(err & 0xFFFF),
			Text:      C.GoString(C.Vix_GetErrorText(err, nil)),
		}
	}

	return C.GoString(path), nil
}
開發者ID:hooklift,項目名稱:govix,代碼行數:21,代碼來源:guest.go

示例13: Description

// Description returns user defined description for the snapshot.
func (s *Snapshot) Description() (string, error) {
	var err C.VixError = C.VIX_OK
	var desc *C.char

	err = C.get_property(s.handle,
		C.VIX_PROPERTY_SNAPSHOT_DESCRIPTION,
		unsafe.Pointer(&desc))

	defer C.Vix_FreeBuffer(unsafe.Pointer(desc))

	if C.VIX_OK != err {
		return "", &Error{
			Operation: "snapshot.Description",
			Code:      int(err & 0xFFFF),
			Text:      C.GoString(C.Vix_GetErrorText(err, nil)),
		}
	}

	return C.GoString(desc), nil
}
開發者ID:hooklift,項目名稱:govix,代碼行數:21,代碼來源:snapshot.go

示例14: Logout

// Logout removes any guest operating system authentication
// context created by a previous call to VM.LoginInGuest().
//
// Remarks:
//   * This function has no effect and returns success if VM.LoginInGuest()
//     has not been called.
//   * If you call this function while guest operations are in progress,
//     subsequent operations may fail with a permissions error.
//     It is best to wait for guest operations to complete before logging out.
//
// Since VMware Workstation 6.0
// Minimum Supported Guest OS: Microsoft Windows NT Series, Linux
func (g *Guest) Logout() error {
	var jobHandle C.VixHandle = C.VIX_INVALID_HANDLE
	var err C.VixError = C.VIX_OK

	jobHandle = C.VixVM_LogoutFromGuest(g.handle,
		nil, // callbackProc
		nil) // clientData

	defer C.Vix_ReleaseHandle(jobHandle)

	err = C.vix_job_wait(jobHandle)
	if C.VIX_OK != err {
		return &Error{
			Operation: "guest.Logout",
			Code:      int(err & 0xFFFF),
			Text:      C.GoString(C.Vix_GetErrorText(err, nil)),
		}
	}

	return nil
}
開發者ID:hooklift,項目名稱:govix,代碼行數:33,代碼來源:guest.go

示例15: Parent

// Parent returns the parent of a snapshot.
//
// Remarks:
//
//   * This function is not supported when using the VMWARE_PLAYER provider
//
// Since VMware Workstation 6.0
func (s *Snapshot) Parent() (*Snapshot, error) {
	var snapshotHandle C.VixHandle = C.VIX_INVALID_HANDLE
	var err C.VixError = C.VIX_OK

	err = C.VixSnapshot_GetParent(s.handle,
		&snapshotHandle) //(output) A handle to the child snapshot.

	if C.VIX_OK != err {
		return nil, &Error{
			Operation: "snapshot.Parent",
			Code:      int(err & 0xFFFF),
			Text:      C.GoString(C.Vix_GetErrorText(err, nil)),
		}
	}

	snapshot := &Snapshot{
		handle: snapshotHandle,
	}

	runtime.SetFinalizer(snapshot, cleanupSnapshot)

	return snapshot, nil
}
開發者ID:hooklift,項目名稱:govix,代碼行數:30,代碼來源:snapshot.go


注:本文中的C.Vix_GetErrorText函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。