// deleteOSFile deletes the OS file from the VM's storage account, returns an error if the operation
// does not succeed.
428709
func (vm *VM) deleteVMFiles(authorizer autorest.Authorizer) error {
	storageAccountsClient := armStorage.NewAccountsClient(vm.Creds.SubscriptionID)
	storageAccountsClient.Authorizer = authorizer

	result, err := storageAccountsClient.ListKeys(vm.ResourceGroup, vm.StorageAccount)
	if err != nil {
		return err
	}

	accountKeys := result.Keys
	if accountKeys == nil || len(*accountKeys) == 0 {
		return fmt.Errorf("no account keys for storage account %q", vm.StorageAccount)
	}

	accountKey := *(*accountKeys)[0].Value
	storageClient, err := storage.NewBasicClient(vm.StorageAccount, accountKey)
	if err != nil {
		return err
	}

	// Get a reference to the OS file.
	blobStorageClient := storageClient.GetBlobService()
	container := blobStorageClient.GetContainerReference(vm.StorageContainer)
	osFileBlob := container.GetBlobReference(vm.OsFile)

	// Delete the OS file.
	opts := &storage.DeleteBlobOptions{Timeout: 30} // 30s timeout
	err = osFileBlob.Delete(opts)

	if vm.DiskSize <= 0 {
		return err
	}

	// Delete the disk file.
	diskFileBlob := container.GetBlobReference(vm.DiskFile)
	diskFileErr := diskFileBlob.Delete(opts)
	if err != nil {
		return fmt.Errorf("failed to delete OS file and disk file: %v, %v", err, diskFileErr)
	}

	return diskFileErr
}
687785
func (util *GCEDiskUtil) DeleteVolume(d *gcePersistentDiskDeleter) error {
	cloud, err := getCloudProvider(d.gcePersistentDisk.plugin.host.GetCloudProvider())
	if err != nil {
		return err
	}

	if err = cloud.DeleteDisk(d.pdName); err != nil {
		klog.V(2).Infof("Error deleting GCE PD volume %s: %v", d.pdName, err)
		// GCE cloud provider returns volume.deletedVolumeInUseError when
		// necessary, no handling needed here.
		return err
	}
	klog.V(2).Infof("Successfully deleted GCE PD volume %s", d.pdName)
	return nil
}
75884
func (o *object) Delete() error {
	// this should be path/name ??
	// gou.Debugf("Delete name=%q  sftp.Name()=%q", o.name, o.fi.Name())
	return o.client.Delete(context.Background(), o.name)
}
1167354
func (s *VolumeService) DeleteVolume(p *DeleteVolumeParams) (*DeleteVolumeResponse, error) {
	resp, err := s.cs.newRequest("deleteVolume", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r DeleteVolumeResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
261139
func (api *Client) DeleteMediaFile(name string) error {
	_, _, err := api.makeRequest(http.MethodDelete, fmt.Sprintf("%s/%s", api.concatUserPath(mediaPath), url.QueryEscape(name)))
	return err
}
540605
func (az *Cloud) DeleteFileShare(accountName, accountKey, shareName string) error {
	if err := az.deleteFileShare(accountName, accountKey, shareName); err != nil {
		return err
	}
	klog.V(4).Infof("share %s deleted", shareName)
	return nil
}
158428
func (f *fileStorage) Delete(key string) error {
	return os.Remove(f.filePathToFile(key))
}
1270798
func (b *BigIP) DeleteClientSSLProfile(name string) error {
	return b.delete(uriLtm, uriProfile, uriClientSSL, name)
}
1069145
func (s *storageRESTServer) DeleteFileHandler(w http.ResponseWriter, r *http.Request) {
	if !s.IsValid(w, r) {
		return
	}
	vars := mux.Vars(r)
	volume := vars[storageRESTVolume]
	filePath := vars[storageRESTFilePath]

	err := s.storage.DeleteFile(volume, filePath)
	if err != nil {
		s.writeErrorResponse(w, err)
	}
}
570842
func (vm *VirtualMachine) DeleteVM(ctx context.Context) error {
	destroyTask, err := vm.Destroy(ctx)
	if err != nil {
		klog.Errorf("Failed to delete the VM: %q. err: %+v", vm.InventoryPath, err)
		return err
	}
	return destroyTask.Wait(ctx)
}
52052
func (a *Client) DeleteFilesFileidentifier(params *DeleteFilesFileidentifierParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteFilesFileidentifierNoContent, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewDeleteFilesFileidentifierParams()
	}

	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "DeleteFilesFileidentifier",
		Method:             "DELETE",
		PathPattern:        "/files/{fileidentifier}",
		ProducesMediaTypes: []string{"application/json", "application/x-gzip"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &DeleteFilesFileidentifierReader{formats: a.formats},
		AuthInfo:           authInfo,
	})
	if err != nil {
		return nil, err
	}
	return result.(*DeleteFilesFileidentifierNoContent), nil
}
274639
func (l *ossObjects) DeleteObject(ctx context.Context, bucket, object string) error {
	bkt, err := l.Client.Bucket(bucket)
	if err != nil {
		logger.LogIf(ctx, err)
		return ossToObjectError(err, bucket, object)
	}

	err = bkt.DeleteObject(object)
	if err != nil {
		logger.LogIf(ctx, err)
		return ossToObjectError(err, bucket, object)
	}
	return nil
}
602712
func CloseFile(f *os.File) {
	if err := f.Close(); err != nil {
		glog.Warningf("unable to close file %s: %v", f.Name(), err)
	}
}
114017
func (m *DatastoreFileManager) Delete(ctx context.Context, name string) error {
	switch path.Ext(name) {
	case ".vmdk":
		return m.DeleteVirtualDisk(ctx, name)
	default:
		return m.DeleteFile(ctx, name)
	}
}
556053
func (vf *virtualFile) close() error {
	if vf.closed {
		return &os.PathError{
			Op:   "close",
			Path: vf.EmbeddedFile.Filename,
			Err:  errors.New("already closed"),
		}
	}
	vf.EmbeddedFile = nil
	vf.closed = true
	return nil
}
711756
func removeSessionFile(sid string) {
	sessionFile, err := getSessionFile(sid)
	if err != nil {
		return
	}
	os.Remove(sessionFile)
}
85431
func (api *Client) DeleteFile(fileID string) error {
	return api.DeleteFileContext(context.Background(), fileID)
}