VirtualBox

source: vbox/trunk/include/iprt/tar.h@ 97778

Last change on this file since 97778 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.9 KB
Line 
1/** @file
2 * IPRT - Tar archive I/O.
3 */
4
5/*
6 * Copyright (C) 2009-2022 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
34 */
35
36#ifndef IPRT_INCLUDED_tar_h
37#define IPRT_INCLUDED_tar_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#include <iprt/cdefs.h>
43#include <iprt/types.h>
44#include <iprt/time.h>
45
46RT_C_DECLS_BEGIN
47
48/** @defgroup grp_rt_tar RTTar - Tar archive I/O
49 * @ingroup grp_rt
50 *
51 * @deprecated Only used for legacy code and writing. Migrate new code to the
52 * VFS interface, add the write part when needed.
53 *
54 * @{
55 */
56
57/** A tar handle */
58typedef R3PTRTYPE(struct RTTARINTERNAL *) RTTAR;
59/** Pointer to a RTTAR interface handle. */
60typedef RTTAR *PRTTAR;
61/** Nil RTTAR interface handle. */
62#define NIL_RTTAR ((RTTAR)0)
63
64/** A tar file handle */
65typedef R3PTRTYPE(struct RTTARFILEINTERNAL *) RTTARFILE;
66/** Pointer to a RTTARFILE interface handle. */
67typedef RTTARFILE *PRTTARFILE;
68/** Nil RTTARFILE interface handle. */
69#define NIL_RTTARFILE ((RTTARFILE)0)
70
71/** Maximum length of a tar filename, excluding the terminating '\0'. More
72 * does not fit into a tar record. */
73#define RTTAR_NAME_MAX 99
74
75/**
76 * Creates a Tar archive.
77 *
78 * Use the mask to specify the access type.
79 *
80 * @returns IPRT status code.
81 *
82 * @param phTar Where to store the RTTAR handle.
83 * @param pszTarname The file name of the tar archive to create. Should
84 * not exist.
85 * @param fMode Open flags, i.e a combination of the RTFILE_O_* defines.
86 * The ACCESS, ACTION and DENY flags are mandatory!
87 */
88RTR3DECL(int) RTTarOpen(PRTTAR phTar, const char *pszTarname, uint32_t fMode);
89
90/**
91 * Close the Tar archive.
92 *
93 * @returns IPRT status code.
94 *
95 * @param hTar Handle to the RTTAR interface.
96 */
97RTR3DECL(int) RTTarClose(RTTAR hTar);
98
99/**
100 * Open a file in the Tar archive.
101 *
102 * @returns IPRT status code.
103 *
104 * @param hTar The handle of the tar archive.
105 * @param phFile Where to store the handle to the opened file.
106 * @param pszFilename Path to the file which is to be opened. (UTF-8)
107 * @param fOpen Open flags, i.e a combination of the RTFILE_O_* defines.
108 * The ACCESS, ACTION flags are mandatory! DENY flags
109 * are currently not supported.
110 *
111 * @remarks Write mode means append mode only. It is not possible to make
112 * changes to existing files.
113 *
114 * @remarks Currently it is not possible to open more than one file in write
115 * mode. Although open more than one file in read only mode (even when
116 * one file is opened in write mode) is always possible.
117 */
118RTR3DECL(int) RTTarFileOpen(RTTAR hTar, PRTTARFILE phFile, const char *pszFilename, uint32_t fOpen);
119
120/**
121 * Close the file opened by RTTarFileOpen.
122 *
123 * @returns IPRT status code.
124 *
125 * @param hFile The file handle to close.
126 */
127RTR3DECL(int) RTTarFileClose(RTTARFILE hFile);
128
129/**
130 * Read bytes from a file at a given offset.
131 * This function may modify the file position.
132 *
133 * @returns IPRT status code.
134 *
135 * @param hFile Handle to the file.
136 * @param off Where to read.
137 * @param pvBuf Where to put the bytes we read.
138 * @param cbToRead How much to read.
139 * @param pcbRead Where to return how much we actually read. If NULL
140 * an error will be returned for a partial read.
141 */
142RTR3DECL(int) RTTarFileReadAt(RTTARFILE hFile, uint64_t off, void *pvBuf, size_t cbToRead, size_t *pcbRead);
143
144/**
145 * Write bytes to a file at a given offset.
146 * This function may modify the file position.
147 *
148 * @returns IPRT status code.
149 *
150 * @param hFile Handle to the file.
151 * @param off Where to write.
152 * @param pvBuf What to write.
153 * @param cbToWrite How much to write.
154 * @param pcbWritten Where to return how much we actually wrote. If NULL
155 * an error will be returned for a partial write.
156 */
157RTR3DECL(int) RTTarFileWriteAt(RTTARFILE hFile, uint64_t off, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten);
158
159/**
160 * Query the size of the file.
161 *
162 * @returns IPRT status code.
163 *
164 * @param hFile Handle to the file.
165 * @param pcbSize Where to store the filesize.
166 */
167RTR3DECL(int) RTTarFileGetSize(RTTARFILE hFile, uint64_t *pcbSize);
168
169/**
170 * Set the size of the file.
171 *
172 * @returns IPRT status code.
173 *
174 * @param hFile Handle to the file.
175 * @param cbSize The new file size.
176 */
177RTR3DECL(int) RTTarFileSetSize(RTTARFILE hFile, uint64_t cbSize);
178
179/** @} */
180
181RT_C_DECLS_END
182
183#endif /* !IPRT_INCLUDED_tar_h */
184
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette