t9t / gomft Goto Github PK
View Code? Open in Web Editor NEWNTFS Master File Table (MFT) parser for Go.
License: MIT License
NTFS Master File Table (MFT) parser for Go.
License: MIT License
I just want to say, that I've seen and produced a truckload of Go code, and the overall code quality of this library is very, very good!
A few highlights:
Line 378 in f64df39
Good job! You rock.
Sorry to spam issue tracker, I couldn't find other contact details :)
Thank you for sharing the code of this library. As a newbie to MFT, could you write an example? I would greatly appreciate it if you could read the $MFT file directly without copying it, and then parse out the file name of each file.
When offsetLength
is zero, it has special semantic meaning (= sparse file):
Line 365 in f64df39
(source, see "Example 4 - Sparse, Unfragmented File")
This code decodes a sparse offset as 0, which would incorrectly read a fragment beginning from first cluster of volume (= VBR).
My initial naive idea was to mark sparse runs as having offset -1, but that's incorrect as each run's offset is relative to previous run, i.e. negative values are legal. I solved this issue in my code by making the offset a pointer to an integer, i.e. nil
means it's sparse.
Directly related to this, DataRunsToFragments
needs to take sparse runs into account. Data run offsets are relative previous non-sparse run, not previous run:
Line 390 in f64df39
This assignment can only be done if current run is non-sparse. I suggest renaming the variable to e.g. previousNonSparseOffsetCluster
.
Natural consequence of sparse run support is supporting sparse fragments, which I again marked as *int
to discriminate between sparse and non-sparse runs. I had to re-write fragment.Reader
in my project because alternating between actual disk-backed fragments vs sparse fragments would've been hackish to add without a re-write.
func ParseDataRuns(b []byte) ([]DataRun, error) {
...
dataLength := binary.LittleEndian.Uint64(padTo(lengthBytes, 8))
....
dataOffset := int64(binary.LittleEndian.Uint64(padTo(offsetBytes, 8)))
}
func padTo(data []byte, length int) []byte {
.....
if data[len(data)-1]&0b10000000 == 0b10000000 {
for i := len(data); i < length; i++ {
result[i] = 0xFF
}
}
return result
}
go run .\gomft.go
bug info
E:\go\src\github.com\t9t\gomft\mft\mft.go:407:24: syntax error: unexpected b10000000, expecting {
E:\go\src\github.com\t9t\gomft\mft\mft.go:408:3: syntax error: unexpected for, expecting expression
E:\go\src\github.com\t9t\gomft\mft\mft.go:412:2: syntax error: non-declaration statement outside function body
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.