Code Monkey home page Code Monkey logo

gomft's People

Contributors

jpohls1 avatar t9t avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gomft's Issues

Thank you

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:

  • The code is self-documenting,
  • The package structure is sensible, e.g. boot sector stuff in own package
  • I would've had to build a "fragment reader" myself, but you had it ready. It was a joy. :)
  • Where you saw fit to add comments, they were truly for need like this line
    // fragment.Reader). Note that data will probably not align to a cluster exactly so there could be some padding at the
    (when I saw that I immediately realized what the bug in my software was)

Good job! You rock.

Sorry to spam issue tracker, I couldn't find other contact details :)

Sparse data runs handling bug

When offsetLength is zero, it has special semantic meaning (= sparse file):

offsetBytes := dataRunData.Read(lengthLength, offsetLength)

(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:

previousOffsetCluster = exactClusterOffset

(link to "Example 4 - Sparse, Unfragmented File" explains this)

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.

mft.ParseDataRuns returns invalid values

  • in "padTo" function , I don't get the point of filling 0xff to the return value. maybe you should jsut remove it
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
}

unavailable

go run .\gomft.go
bug info

github.com/t9t/gomft/mft

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.