Adds the possiblility to append to files to obidistribute

This commit is contained in:
2023-02-16 16:13:13 +01:00
parent 85349668d0
commit 2975042982
6 changed files with 74 additions and 4 deletions

View File

@ -55,7 +55,18 @@ func WriteSequencesToFile(iterator obiiter.IBioSequence,
filename string,
options ...WithOption) (obiiter.IBioSequence, error) {
file, err := os.Create(filename)
var file *os.File
var err error
opt := MakeOptions(options)
if opt.AppendFile() {
log.Debug("Open files in appending mode")
file, err = os.OpenFile(filename,
os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
} else {
file, err = os.Create(filename)
}
if err != nil {
log.Fatalf("open file error: %v", err)