Add minitar_rewind()
This commit is contained in:
parent
c05a8e1b07
commit
8507f57bc1
2
Makefile
2
Makefile
@ -6,7 +6,7 @@ SRC := src
|
|||||||
CC ?= gcc
|
CC ?= gcc
|
||||||
AR ?= ar
|
AR ?= ar
|
||||||
CFLAGS ?= -O2 -Wall -Wextra
|
CFLAGS ?= -O2 -Wall -Wextra
|
||||||
CFLAGS := ${CFLAGS} -I. -D_IN_MINITAR
|
CFLAGS := ${CFLAGS} -I.
|
||||||
DESTDIR ?= /usr/local
|
DESTDIR ?= /usr/local
|
||||||
|
|
||||||
OBJS := $(OBJ)/tar.o \
|
OBJS := $(OBJ)/tar.o \
|
||||||
|
@ -59,6 +59,11 @@ This function returns NULL on end-of-file (when all entries have been read).
|
|||||||
|
|
||||||
Frees the heap-allocated `struct minitar_entry` and the file contents stored inside it. The pointer passed to `minitar_free_entry()` should be the return value of a previous call to `minitar_read_entry()`.
|
Frees the heap-allocated `struct minitar_entry` and the file contents stored inside it. The pointer passed to `minitar_free_entry()` should be the return value of a previous call to `minitar_read_entry()`.
|
||||||
|
|
||||||
|
### minitar_rewind
|
||||||
|
`void minitar_rewind(struct minitar* mp)`
|
||||||
|
|
||||||
|
Rewinds the `struct minitar` back to the beginning of the archive file, which means that the next call to `minitar_read_entry()` will return the first entry instead of the entry after the last read entry.
|
||||||
|
|
||||||
### minitar_close
|
### minitar_close
|
||||||
`int minitar_close(struct minitar* mp)`
|
`int minitar_close(struct minitar* mp)`
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#ifndef MINITAR_H
|
#ifndef MINITAR_H
|
||||||
#define MINITAR_H
|
#define MINITAR_H
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#ifdef _IN_MINITAR
|
#ifdef _IN_MINITAR
|
||||||
|
#include <stdio.h>
|
||||||
struct minitar
|
struct minitar
|
||||||
{
|
{
|
||||||
FILE* stream;
|
FILE* stream;
|
||||||
@ -42,6 +42,7 @@ struct minitar_entry
|
|||||||
struct minitar* minitar_open(const char* pathname);
|
struct minitar* minitar_open(const char* pathname);
|
||||||
struct minitar_entry* minitar_read_entry(struct minitar* mp);
|
struct minitar_entry* minitar_read_entry(struct minitar* mp);
|
||||||
void minitar_free_entry(struct minitar_entry* entry);
|
void minitar_free_entry(struct minitar_entry* entry);
|
||||||
|
void minitar_rewind(struct minitar* mp);
|
||||||
int minitar_close(struct minitar* mp);
|
int minitar_close(struct minitar* mp);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,3 +1,4 @@
|
|||||||
|
#define _IN_MINITAR
|
||||||
#include "tar.h"
|
#include "tar.h"
|
||||||
#include "minitar.h"
|
#include "minitar.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -62,6 +63,11 @@ struct minitar_entry* minitar_read_entry(struct minitar* mp)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void minitar_rewind(struct minitar* mp)
|
||||||
|
{
|
||||||
|
rewind(mp->stream);
|
||||||
|
}
|
||||||
|
|
||||||
void minitar_free_entry(struct minitar_entry* entry)
|
void minitar_free_entry(struct minitar_entry* entry)
|
||||||
{
|
{
|
||||||
free(entry->ptr);
|
free(entry->ptr);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#define _POSIX_C_SOURCE 200809L
|
#define _POSIX_C_SOURCE 200809L // for strndup
|
||||||
|
#define _IN_MINITAR
|
||||||
#include "minitar.h"
|
#include "minitar.h"
|
||||||
#include "tar.h"
|
#include "tar.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user