本文整理汇总了Golang中github.com/blang/vfs.Filesystem.Mkdir方法的典型用法代码示例。如果您正苦于以下问题:Golang Filesystem.Mkdir方法的具体用法?Golang Filesystem.Mkdir怎么用?Golang Filesystem.Mkdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/blang/vfs.Filesystem
的用法示例。
在下文中一共展示了Filesystem.Mkdir方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ExampleMyFilesystem
func ExampleMyFilesystem() {
// Simply bootstrap your filesystem
var fs vfs.Filesystem = MyFS()
err := fs.Mkdir("/tmp", 0777)
if err != nil {
fatal("Error will be: Not implemented yet!")
}
}
示例2: ExampleMyWrapper
func ExampleMyWrapper() {
// Disable Mkdirs on the OS Filesystem
var fs vfs.Filesystem = NoNewDirs(vfs.OS())
err := fs.Mkdir("/tmp", 0777)
if err != nil {
fatal("Mkdir disabled!")
}
}
示例3: ExampleOsFS_myWrapper
func ExampleOsFS_myWrapper() {
// Disable Mkdirs on the OS Filesystem
var fs vfs.Filesystem = NoNewDirs(vfs.OS())
err := fs.Mkdir("/tmp", 0777)
if err != nil {
fmt.Printf("Mkdir disabled!\n")
}
}
示例4: ExampleDummyFS
func ExampleDummyFS() {
// Simply bootstrap your filesystem
var fs vfs.Filesystem = MyFS()
// Your mkdir implementation
fs.Mkdir("/tmp", 0777)
// All necessary methods like OpenFile (therefor Create) are stubbed
// and return the dummys error
_, err := vfs.Create(fs, "/tmp/vfs/example.txt")
if err != nil {
fmt.Printf("Error will be: Not implemented yet!\n")
}
}
示例5: Example
func Example() {
// Create a vfs accessing the filesystem of the underlying OS
var osfs vfs.Filesystem = vfs.OS()
osfs.Mkdir("/tmp", 0777)
// Make the filesystem read-only:
osfs = vfs.ReadOnly(osfs) // Simply wrap filesystems to change its behaviour
// os.O_CREATE will fail and return vfs.ErrReadOnly
// os.O_RDWR is supported but Write(..) on the file is disabled
f, _ := osfs.OpenFile("/tmp/example.txt", os.O_RDWR, 0)
// Return vfs.ErrReadOnly
_, err := f.Write([]byte("Write on readonly fs?"))
if err != nil {
fmt.Errorf("Filesystem is read only!\n")
}
// Create a fully writable filesystem in memory
mfs := memfs.Create()
mfs.Mkdir("/root", 0777)
// Create a vfs supporting mounts
// The root fs is accessing the filesystem of the underlying OS
fs := mountfs.Create(osfs)
// Mount a memfs inside /memfs
// /memfs may not exist
fs.Mount(mfs, "/memfs")
// This will create /testdir inside the memfs
fs.Mkdir("/memfs/testdir", 0777)
// This would create /tmp/testdir inside your OS fs
// But the rootfs `osfs` is read-only
fs.Mkdir("/tmp/testdir", 0777)
}
示例6: TestInterface
func TestInterface(t *testing.T) {
var fs vfs.Filesystem
fs = Create()
fs.Mkdir("/tmp", 0777)
}