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


Golang Fs.Mkdir方法代碼示例

本文整理匯總了Golang中github.com/ncw/rclone/fs.Fs.Mkdir方法的典型用法代碼示例。如果您正苦於以下問題:Golang Fs.Mkdir方法的具體用法?Golang Fs.Mkdir怎麽用?Golang Fs.Mkdir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/ncw/rclone/fs.Fs的用法示例。


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

示例1: WriteObjectTo

// WriteObjectTo writes an object to the fs, remote passed in
func (r *Run) WriteObjectTo(f fs.Fs, remote, content string, modTime time.Time, useUnchecked bool) fstest.Item {
	put := f.Put
	if useUnchecked {
		if fPutUnchecked, ok := f.(fs.PutUncheckeder); ok {
			put = fPutUnchecked.PutUnchecked
		} else {
			r.Fatalf("Fs doesn't support PutUnchecked")
		}
	}
	const maxTries = 5
	if !r.mkdir[f.String()] {
		err := f.Mkdir()
		if err != nil {
			r.Fatalf("Failed to mkdir %q: %v", f, err)
		}
		r.mkdir[f.String()] = true
	}
	for tries := 1; ; tries++ {
		in := bytes.NewBufferString(content)
		objinfo := fs.NewStaticObjectInfo(remote, modTime, int64(len(content)), true, nil, nil)
		_, err := put(in, objinfo)
		if err == nil {
			break
		}
		// Retry if err returned a retry error
		if fs.IsRetryError(err) && tries < maxTries {
			r.Logf("Retry Put of %q to %v: %d/%d (%v)", remote, f, tries, maxTries, err)
			continue
		}
		r.Fatalf("Failed to put %q to %q: %v", remote, f, err)
	}
	return fstest.NewItem(remote, content, modTime)
}
開發者ID:yut148,項目名稱:rclone,代碼行數:34,代碼來源:operations_test.go

示例2: ForceMkdir

// ForceMkdir creates the remote
func (r *Run) ForceMkdir(f fs.Fs) {
	err := f.Mkdir("")
	if err != nil {
		r.Fatalf("Failed to mkdir %q: %v", f, err)
	}
	r.mkdir[f.String()] = true
}
開發者ID:ncw,項目名稱:rclone,代碼行數:8,代碼來源:operations_test.go

示例3: WriteObjectTo

// WriteObjectTo writes an object to the fs, remote passed in
func (r *Run) WriteObjectTo(f fs.Fs, remote, content string, modTime time.Time) fstest.Item {
	const maxTries = 5
	if !r.mkdir[f.String()] {
		err := f.Mkdir()
		if err != nil {
			r.Fatalf("Failed to mkdir %q: %v", f, err)
		}
		r.mkdir[f.String()] = true
	}
	for tries := 1; ; tries++ {
		in := bytes.NewBufferString(content)
		_, err := f.Put(in, remote, modTime, int64(len(content)))
		if err == nil {
			break
		}
		// Retry if err returned a retry error
		if retry, ok := err.(fs.Retry); ok && retry.Retry() && tries < maxTries {
			r.Logf("Retry Put of %q to %v: %d/%d (%v)", remote, f, tries, maxTries, err)
			continue
		}
		r.Fatalf("Failed to put %q to %q: %v", remote, f, err)
	}
	return fstest.NewItem(remote, content, modTime)
}
開發者ID:vanphong3783,項目名稱:rclone,代碼行數:25,代碼來源:operations_test.go


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