Created
March 30, 2014 21:44
-
-
Save wkharold/9880360 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** job.go ***/ | |
// Read handles read operations on a jobfile using its associated reader. | |
func (jf jobfile) Read(fid *srv.FFid, buf []byte, offset uint64) (int, error) { | |
glog.V(4).Infof("Entering jobfile.Read(%v, %v, %)", fid, buf, offset) | |
defer glog.V(4).Infof("Exiting jobfile.Read(%v, %v, %v)", fid, buf, offset) | |
cont := jf.reader() | |
if offset > uint64(len(cont)) { | |
return 0, nil | |
} | |
contout := cont[offset:] | |
copy(buf, contout) | |
return len(contout), nil | |
} | |
// Write handles write operations on a jobfile using its associated writer. | |
func (jf *jobfile) Write(fid *srv.FFid, data []byte, offset uint64) (int, error) { | |
glog.V(4).Infof("Entering jobfile.Write(%v, %v, %v)", fid, data, offset) | |
defer glog.V(4).Infof("Exiting jobfile.Write(%v, %v, %v)", fid, data, offset) | |
jf.Parent.Lock() | |
defer jf.Parent.Unlock() | |
return jf.writer(data) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment