dirtreehash's Introduction
## 小工具需求说明 1. 对整个目录下的所有文件进行遍历,获取所有文件的大小和计算文件的sha1哈希值,记录在一个文件里面,并保存在hashResult目录下 2. 结果文件格式:每一行一个文件,用逗号隔开,前面是文件名称,后面是哈希值,文件大小 3. 可以在目录中增加.sha1Ignore文件,将需要忽略的文件加入,【**目前尚未支持通配符**】
dirtreehash's People
dirtreehash's Issues
对golang标准库的不熟悉
描述
对于某些实现,在标准库中,已经内置了相应的方法,不用自己再去实现
func walkDir(dir string, wait *sync.WaitGroup, hashStr chan<- string) {
defer wait.Done()
ignores := getIgnoreFiles(dir)
for _, entry := range dirents(dir) {
//忽略文件
name := entry.Name()
if ignores != nil && ignores[name] {
continue
}
if entry.IsDir() {
wait.Add(1)
subdir := filepath.Join(dir, name)
go walkDir(subdir, wait, hashStr)
} else {
fileFullName := filepath.Join(dir, name)
fileSize := entry.Size()
fileHash := getHash(fileFullName)
hashStr <- fmt.Sprintf("%s, %v, %d\n", fileFullName, fileHash, fileSize)
}
}
}
大文件处理
描述
未进行大文件处理
func getHash(file string) []byte {
f, err := os.Open(file)
if err != nil {
fmt.Printf("Open:%s error", file)
panic(err)
}
defer f.Close()
h := sha1.New()
_, err = io.Copy(h, f)
if err != nil {
panic(err)
}
return h.Sum(nil)
}
导出的hash的显示问题
描述
在导出文件中,文件hash是[]byte,我想这不是我们想要看到的结果
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.