1 /******************************************************************************
4 * Copyright (c) 2020, longpanda <admin@ventoy.net>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
29 extern int g_biso_debug
;
30 void BISO_SetDebug(int debug
);
32 #define BISO_DIAG(fmt, ...) if(g_biso_debug) printf(fmt, ##__VA_ARGS__)
33 #define BISO_DUMP printf
60 #define UCHAR unsigned char
68 #define USHORT unsigned short
76 #define ULONG unsigned long
80 #define ULONGLONG unsigned long long
89 #define UINT unsigned int
97 #define UINT16 unsigned short
105 #define UINT32 unsigned int
109 typedef USHORT BOOL_T
;
110 #define BOOL_TRUE ((BOOL_T)1)
111 #define BOOL_FALSE ((BOOL_T)0)
114 typedef long long INT64
;
115 typedef unsigned long long UINT64
;
117 #define BISO_PATH_STRCMP strcmp
120 #define NULL (void *)0
138 typedef VOID BISO_READ_S
;
139 typedef VOID BISO_WRITE_S
;
140 typedef CONST VOID
* BISO_HANDLE
;
143 #define BISO_SUCCESS 0
144 #define BISO_ERR_BASE 0x1000
145 #define BISO_ERR_FAILED (BISO_ERR_BASE + 1)
146 #define BISO_ERR_NULL_PTR (BISO_ERR_BASE + 2)
147 #define BISO_ERR_ALLOC_MEM (BISO_ERR_BASE + 3)
148 #define BISO_ERR_OPEN_FILE (BISO_ERR_BASE + 4)
149 #define BISO_ERR_READ_FILE (BISO_ERR_BASE + 5)
150 #define BISO_ERR_WRITE_FILE (BISO_ERR_BASE + 6)
151 #define BISO_ERR_INVALID_ISO9660 (BISO_ERR_BASE + 7)
152 #define BISO_ERR_UNSUPPORTED_BLKSIZE (BISO_ERR_BASE + 8)
153 #define BISO_ERR_INVALID_PARAM (BISO_ERR_BASE + 9)
154 #define BISO_ERR_NOT_FOUND (BISO_ERR_BASE + 10)
155 #define BISO_ERR_NOT_RECORD (BISO_ERR_BASE + 11)
156 #define BISO_ERR_HANDLE_UNINITIALIZED (BISO_ERR_BASE + 12)
157 #define BISO_ERR_INVALID_RRIP_SP (BISO_ERR_BASE + 13)
158 #define BISO_ERR_ABORT (BISO_ERR_BASE + 14)
160 typedef struct tagBISO_VOLUME_SUMMARY
164 CHAR szPublisherId
[129];
165 CHAR szPreparerId
[129];
166 CHAR szApplicationId
[129];
167 CHAR szCopyrightFileId
[38];
168 CHAR szAbstractFileId
[38];
176 }BISO_VOLUME_SUMMARY_S
;
178 #define BISO_TREE_FLAG_CUR 1
179 #define BISO_TREE_FLAG_DFS 2
180 #define BISO_TREE_FLAG_BFS 3
183 typedef struct tagBISO_DATE
195 typedef enum tagBISO_DATE_TYPE
197 BISO_DATE_TYPE_CREATE
= 0,
198 BISO_DATE_TYPE_MODIFY
,
199 BISO_DATE_TYPE_EXPIRATION
,
200 BISO_DATE_TYPE_EFFECTIVE
,
205 typedef struct tagBISO_DIR_STAT
219 #define BISO_NODE_REGFILE 1
220 #define BISO_NODE_SYMLINK 2
221 #define BISO_NODE_DIRECTORY 4
224 typedef struct tagBISO_FILE_NODE
230 * BISO_NODE_DIRECTORY
237 UINT64 ui64DirRecOffet
;
239 BISO_HANDLE hCurrent
;
242 typedef struct tagBISO_SVD_FILE_NODE
246 UINT64 ui64DirRecOffet
;
247 }BISO_SVD_FILE_NODE_S
;
250 #define BISO_EXTRACT_TIME_FOLLOW 1
251 #define BISO_EXTRACT_TIME_SPECIFY 2
253 typedef struct tagBISO_EXTRACT_CTRL
259 }BISO_EXTRACT_CTRL_S
;
261 #define BISO_EXTRACT_MSG_MAKE_DIR 1
262 #define BISO_EXTRACT_MSG_CREATE_FILE 2
263 #define BISO_EXTRACT_MSG_SYMLINK 3
265 typedef struct tagBISO_EXTRACT_NOTIFY
269 CONST CHAR
*pcFileName
;
270 }BISO_EXTRACT_NOTIFY_S
;
272 typedef ULONG (* BISO_EXTRACE_CB_PF
)(IN CONST BISO_EXTRACT_NOTIFY_S
*pstNotify
);
274 CONST CHAR
* BISO_GetErrMsg(IN ULONG ulErrCode
);
276 VOID
BISO_GetNow(OUT BISO_DATE_S
*pstTM
);
278 VOID
BISO_TimeConv(IN ULONG ulTime
, OUT BISO_DATE_S
*pstTM
);
280 BISO_READ_S
* BISO_AllocReadHandle(VOID
);
282 VOID
BISO_FreeReadHandle(INOUT BISO_READ_S
*pstRead
);
284 BOOL_T
BISO_IsISOFile(IN CONST CHAR
*pcFileName
);
286 BOOL_T
BISO_IsUDFFile(IN CONST CHAR
*pcFileName
);
288 ULONG
BISO_OpenImage(IN CONST CHAR
*pcFileName
, OUT BISO_READ_S
*pstRead
);
289 ULONG
BISO_OpenImageWithSVD(IN CONST CHAR
*pcFileName
, OUT BISO_READ_S
*pstRead
);
290 BOOL_T
BISO_HasSVD(IN CONST BISO_READ_S
*pstRead
);
292 ULONG BISO_GetVolumeSummary
294 IN CONST BISO_READ_S
*pstRead
,
295 OUT BISO_VOLUME_SUMMARY_S
*pstSummary
300 IN CONST BISO_READ_S
*pstRead
,
301 IN BISO_DATE_TYPE_E enType
,
302 OUT BISO_DATE_S
*pstDate
305 UINT
BISO_GetRockRidgeVer(IN CONST BISO_READ_S
*pstRead
);
307 UINT
BISO_GetJolietLevel(IN CONST BISO_READ_S
*pstRead
);
309 BISO_HANDLE
BISO_GetRoot(IN CONST BISO_READ_S
*pstRead
);
311 ULONG BISO_GetFileNodeByHdl
313 IN BISO_HANDLE hFileHdl
,
314 OUT BISO_FILE_NODE_S
*pstFileNode
317 ULONG BISO_GetFileNodeByName
319 IN CONST BISO_READ_S
*pstRead
,
320 IN CONST CHAR
*pcFullPath
,
321 IN UCHAR ucFollowLink
,
322 OUT BISO_FILE_NODE_S
*pstFileNode
325 ULONG BISO_GetFileNodeByExtent
327 IN CONST BISO_READ_S
*pstRead
,
329 OUT BISO_FILE_NODE_S
*pstFileNode
332 ULONG BISO_GetSVDFileNodeByExtent
334 IN CONST BISO_READ_S
*pstRead
,
336 OUT BISO_SVD_FILE_NODE_S
*pstFileNode
339 ULONG BISO_GetFileTree
341 IN BISO_HANDLE hTopDir
,
343 OUT BISO_HANDLE
*phFileTree
,
347 ULONG BISO_GetDirStat
349 IN BISO_HANDLE hTopDir
,
350 OUT BISO_DIR_STAT_S
*pstDirStat
353 ULONG BISO_ExtractFile
355 IN CONST BISO_READ_S
*pstRead
,
356 IN CONST BISO_HANDLE hTopDir
,
357 IN CONST CHAR
*pcDstPath
,
358 IN CONST BISO_EXTRACT_CTRL_S
*pstCtrl
,
359 IN BISO_EXTRACE_CB_PF pfCallBack
362 VOID
BISO_Fill733(IN UINT uiData
, OUT VOID
*pBuf
);
363 UINT
BISO_Get733(IN CONST VOID
*pBuf
);
364 UINT
BISO_GetFileOccupySize(IN UINT uiRawSize
);
365 UINT
BISO_GetBootEntryNum(IN CONST BISO_READ_S
*pstRead
);
367 VOID
BISO_DumpVD(IN CONST BISO_READ_S
*pstRead
);
369 VOID
BISO_DumpPathTable(IN CONST BISO_READ_S
*pstRead
);
371 VOID
BISO_DumpFileTree(IN CONST BISO_READ_S
*pstRead
);
373 typedef struct tagBISO_FILE
379 UINT64
BISO_PLAT_GetFileSize(IN CONST CHAR
*pcFileName
);
383 IN CONST CHAR
*pcFileName
,
384 IN CONST BISO_DATE_S
*pstAccessTime
,
385 IN CONST BISO_DATE_S
*pstModifyTime
388 BOOL_T
BISO_PLAT_IsPathExist(IN CONST CHAR
*pcPath
);
390 BOOL_T
BISO_PLAT_IsFileExist(IN CONST CHAR
*pcFilePath
);
392 ULONG
BISO_PLAT_MkDir(IN CONST CHAR
*pcFullPath
);
394 BISO_FILE_S
* BISO_PLAT_OpenExistFile(IN CONST CHAR
*pcFileName
);
395 BISO_FILE_S
* BISO_PLAT_CreateNewFile(IN CONST CHAR
*pcFileName
);
397 VOID
BISO_PLAT_CloseFile(IN BISO_FILE_S
*pstFile
);
399 INT64
BISO_PLAT_SeekFile(BISO_FILE_S
*pstFile
, INT64 i64Offset
, INT iFromWhere
);
401 UINT64 BISO_PLAT_ReadFile
403 IN BISO_FILE_S
*pstFile
,
409 UINT64 BISO_PLAT_WriteFile
411 IN BISO_FILE_S
*pstFile
,
417 CHAR
* BISO_PLAT_GetCurDir(VOID
);
418 UINT64
BISO_UTIL_WholeFile2Buf(IN CONST CHAR
*szFileName
, OUT UCHAR
*pucBuf
);
420 #endif /* __BISO_H__ */