当前位置: 首页>>代码示例>>Golang>>正文


Golang FileSystem.GetFileStatus方法代码示例

本文整理汇总了Golang中vladimirvivien/gowfs.FileSystem.GetFileStatus方法的典型用法代码示例。如果您正苦于以下问题:Golang FileSystem.GetFileStatus方法的具体用法?Golang FileSystem.GetFileStatus怎么用?Golang FileSystem.GetFileStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vladimirvivien/gowfs.FileSystem的用法示例。


在下文中一共展示了FileSystem.GetFileStatus方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: changeGroup

func changeGroup(fs *gowfs.FileSystem, hdfsPath string) {
	shell := gowfs.FsShell{FileSystem: fs}
	_, err := shell.Chgrp([]string{hdfsPath}, "superduper")
	if err != nil {
		log.Fatal("Chgrp failed for ", hdfsPath, ": ", err.Error())
	}
	stat, err := fs.GetFileStatus(gowfs.Path{Name: hdfsPath})
	if err != nil {
		log.Fatal("Unable to validate chgrp() operation: ", err.Error())
	}
	if stat.Group == "superduper" {
		log.Println("Chgrp for ", hdfsPath, " OK ")
		ls(fs, hdfsPath)
	} else {
		log.Fatal("Chgrp() failed.")
	}
}
开发者ID:xiekeyang,项目名称:gowfs,代码行数:17,代码来源:main.go

示例2: changeMod

func changeMod(fs *gowfs.FileSystem, hdfsPath string) {
	shell := gowfs.FsShell{FileSystem: fs}
	_, err := shell.Chmod([]string{hdfsPath}, 0744)
	if err != nil {
		log.Fatal("Chmod() failed for ", hdfsPath, ": ", err.Error())
	}
	stat, err := fs.GetFileStatus(gowfs.Path{Name: hdfsPath})
	if err != nil {
		log.Fatal("Unable to validate Chmod() operation: ", err.Error())
	}
	if stat.Permission == "744" {
		log.Println("Chmod for ", hdfsPath, " OK ")
		ls(fs, hdfsPath)
	} else {
		log.Fatal("Chmod() failed.")
	}
}
开发者ID:xiekeyang,项目名称:gowfs,代码行数:17,代码来源:main.go

示例3: changeOwner

func changeOwner(fs *gowfs.FileSystem, hdfsPath string) {
	shell := gowfs.FsShell{FileSystem: fs}
	_, err := shell.Chown([]string{hdfsPath}, "owner2")
	if err != nil {
		log.Fatal("Chown failed for ", hdfsPath, ": ", err.Error())
	}
	stat, err := fs.GetFileStatus(gowfs.Path{Name: hdfsPath})
	if err != nil {
		log.Fatal("Unable to validate chown() operation: ", err.Error())
	}
	if stat.Owner == "owner2" {
		log.Println("Chown for ", hdfsPath, " OK ")
		ls(fs, hdfsPath)
	} else {
		log.Fatal("Chown() failed.")
	}
}
开发者ID:xiekeyang,项目名称:gowfs,代码行数:17,代码来源:main.go

示例4: moveRemoteFileLocal

func moveRemoteFileLocal(fs *gowfs.FileSystem, remoteFile string) {
	log.Println("Moving Remote file!!")
	shell := gowfs.FsShell{FileSystem: fs}
	remotePath, fileName := path.Split(remoteFile)
	_, err := shell.MoveToLocal(remoteFile, fileName)
	if err != nil {
		log.Fatal("MoveToLocal() failed: ", err.Error())
	}
	file, err := os.Open(fileName)
	if err != nil {
		log.Fatal("MoveToLocal() - local file can't be open. ")
	}
	defer file.Close()
	defer os.Remove(file.Name())

	_, err = fs.GetFileStatus(gowfs.Path{Name: remoteFile})
	if err == nil {
		log.Fatal("Expecing a FileNotFoundException, but file is found. ", remoteFile, ": ", err.Error())
	}
	log.Printf("Remote file %s has been removed Ok", remoteFile)
	ls(fs, remotePath)
}
开发者ID:xiekeyang,项目名称:gowfs,代码行数:22,代码来源:main.go

示例5: appendToRemoteFile

func appendToRemoteFile(fs *gowfs.FileSystem, localFile, hdfsPath string) {
	stat, err := fs.GetFileStatus(gowfs.Path{Name: hdfsPath})
	if err != nil {
		log.Fatal("Unable to get file info for ", hdfsPath, ":", err.Error())
	}
	shell := gowfs.FsShell{FileSystem: fs}
	_, err = shell.AppendToFile([]string{localFile}, hdfsPath)
	if err != nil {
		log.Fatal("AppendToFile() failed: ", err.Error())
	}

	stat2, err := fs.GetFileStatus(gowfs.Path{Name: hdfsPath})
	if err != nil {
		log.Fatal("Something went wrong, unable to get file info:", err.Error())
	}
	if stat2.Length > stat.Length {
		log.Println("AppendToFile() for ", hdfsPath, " OK.")
		ls(fs, hdfsPath)
	} else {
		log.Fatal("AppendToFile failed. File size for ", hdfsPath, " expected to be larger.")
	}
}
开发者ID:xiekeyang,项目名称:gowfs,代码行数:22,代码来源:main.go


注:本文中的vladimirvivien/gowfs.FileSystem.GetFileStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。