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