File: slow5_close.md

package info (click to toggle)
libslow5lib 0.7.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 25,084 kB
  • sloc: ansic: 11,825; python: 1,179; sh: 547; makefile: 90; cpp: 40
file content (57 lines) | stat: -rw-r--r-- 1,548 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# slow5_close

## NAME
slow5_close - closes an open slow5 file and free the associated memory

## SYNOPSYS
`int slow5_close(slow5_file_t *s5p)`

## DESCRIPTION
`slow5_close()` closes a slow5 file and frees the associated *slow5_file_t* structure from memory.
The argument *s5p* is the *slow5_file_t* pointer returned by a previous `slow5_open()` call. If a BLOW5 file had been opened for writing or appending, the SLOW5 EOF marker is appended to the end of the file.

The behaviour of `slow5_close()` is undefined if the parameter is an illegal pointer, or if `slow5_close()` has been previous invoked on the pointer.

If a slow5 index has been associated with the *s5p* structure (using a previous `slow5_idx_load()` invocation), `slow5_idx_unload()` must be invoked before calling `slow5_close()`.



## RETURN VALUE

Upon successful completion, `slow5_close()` returns 0. Otherwise, a negative value (EOF) is returned and `slow5_errno` is set to indicate the error.

## ERRORS

* `SLOW5_ERR_IO`
      File I/O error, for instance, `fclose` failed.

## NOTES

Internally uses `fclose()` to close the file stream and calls `free()` on allocated memory.

## EXAMPLES
```
#include <stdio.h>
#include <stdlib.h>
#include <slow5/slow5.h>

#define FILE_PATH "examples/example.slow5"

int main(){

    slow5_file_t *sp = slow5_open(FILE_PATH,"r");
    if(sp==NULL){
       fprintf(stderr,"Error in opening file\n");
       exit(EXIT_FAILURE);
    }

    //...

    slow5_close(sp);

}
```

## SEE ALSO

[slow5_open()](slow5_open.md)