1544 * the platform's native byte order. |
1548 * the platform's native byte order. |
1545 * |
1549 * |
1546 * \param val value to convert |
1550 * \param val value to convert |
1547 * \return converted value. |
1551 * \return converted value. |
1548 * |
1552 * |
|
1553 * \warning Remember, PHYSFS_sint64 is only 32 bits on platforms without |
|
1554 * any sort of 64-bit support. |
|
1555 */ |
|
1556 PHYSFS_DECL PHYSFS_sint64 PHYSFS_swapSLE64(PHYSFS_sint64 val); |
|
1557 |
|
1558 |
|
1559 /** |
|
1560 * \fn PHYSFS_uint64 PHYSFS_swapULE64(PHYSFS_uint64 val) |
|
1561 * \brief Swap littleendian unsigned 64 to platform's native byte order. |
|
1562 * |
|
1563 * Take a 64-bit unsigned value in littleendian format and convert it to |
|
1564 * the platform's native byte order. |
|
1565 * |
|
1566 * \param val value to convert |
|
1567 * \return converted value. |
|
1568 * |
1549 * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without |
1569 * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without |
1550 * any sort of 64-bit support. |
1570 * any sort of 64-bit support. |
1551 */ |
1571 */ |
1552 PHYSFS_DECL PHYSFS_sint64 PHYSFS_swapSLE64(PHYSFS_sint64 val); |
1572 PHYSFS_DECL PHYSFS_uint64 PHYSFS_swapULE64(PHYSFS_uint64 val); |
1553 |
1573 |
1554 |
1574 |
1555 /** |
1575 /** |
1556 * \fn PHYSFS_uint64 PHYSFS_swapULE64(PHYSFS_uint64 val) |
1576 * \fn PHYSFS_sint16 PHYSFS_swapSBE16(PHYSFS_sint16 val) |
1557 * \brief Swap littleendian unsigned 64 to platform's native byte order. |
1577 * \brief Swap bigendian signed 16 to platform's native byte order. |
1558 * |
1578 * |
1559 * Take a 64-bit unsigned value in littleendian format and convert it to |
1579 * Take a 16-bit signed value in bigendian format and convert it to |
1560 * the platform's native byte order. |
1580 * the platform's native byte order. |
1561 * |
1581 * |
1562 * \param val value to convert |
1582 * \param val value to convert |
1563 * \return converted value. |
1583 * \return converted value. |
1564 * |
1584 */ |
1565 * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without |
1585 PHYSFS_DECL PHYSFS_sint16 PHYSFS_swapSBE16(PHYSFS_sint16 val); |
1566 * any sort of 64-bit support. |
1586 |
1567 */ |
1587 |
1568 PHYSFS_DECL PHYSFS_uint64 PHYSFS_swapULE64(PHYSFS_uint64 val); |
1588 /** |
1569 |
1589 * \fn PHYSFS_uint16 PHYSFS_swapUBE16(PHYSFS_uint16 val) |
1570 |
1590 * \brief Swap bigendian unsigned 16 to platform's native byte order. |
1571 /** |
1591 * |
1572 * \fn PHYSFS_sint16 PHYSFS_swapSBE16(PHYSFS_sint16 val) |
1592 * Take a 16-bit unsigned value in bigendian format and convert it to |
1573 * \brief Swap bigendian signed 16 to platform's native byte order. |
|
1574 * |
|
1575 * Take a 16-bit signed value in bigendian format and convert it to |
|
1576 * the platform's native byte order. |
1593 * the platform's native byte order. |
1577 * |
1594 * |
1578 * \param val value to convert |
1595 * \param val value to convert |
1579 * \return converted value. |
1596 * \return converted value. |
1580 */ |
1597 */ |
1581 PHYSFS_DECL PHYSFS_sint16 PHYSFS_swapSBE16(PHYSFS_sint16 val); |
1598 PHYSFS_DECL PHYSFS_uint16 PHYSFS_swapUBE16(PHYSFS_uint16 val); |
1582 |
1599 |
1583 |
1600 /** |
1584 /** |
1601 * \fn PHYSFS_sint32 PHYSFS_swapSBE32(PHYSFS_sint32 val) |
1585 * \fn PHYSFS_uint16 PHYSFS_swapUBE16(PHYSFS_uint16 val) |
1602 * \brief Swap bigendian signed 32 to platform's native byte order. |
1586 * \brief Swap bigendian unsigned 16 to platform's native byte order. |
1603 * |
1587 * |
1604 * Take a 32-bit signed value in bigendian format and convert it to |
1588 * Take a 16-bit unsigned value in bigendian format and convert it to |
|
1589 * the platform's native byte order. |
1605 * the platform's native byte order. |
1590 * |
1606 * |
1591 * \param val value to convert |
1607 * \param val value to convert |
1592 * \return converted value. |
1608 * \return converted value. |
1593 */ |
1609 */ |
1594 PHYSFS_DECL PHYSFS_uint16 PHYSFS_swapUBE16(PHYSFS_uint16 val); |
1610 PHYSFS_DECL PHYSFS_sint32 PHYSFS_swapSBE32(PHYSFS_sint32 val); |
1595 |
1611 |
1596 /** |
1612 |
1597 * \fn PHYSFS_sint32 PHYSFS_swapSBE32(PHYSFS_sint32 val) |
1613 /** |
1598 * \brief Swap bigendian signed 32 to platform's native byte order. |
1614 * \fn PHYSFS_uint32 PHYSFS_swapUBE32(PHYSFS_uint32 val) |
1599 * |
1615 * \brief Swap bigendian unsigned 32 to platform's native byte order. |
1600 * Take a 32-bit signed value in bigendian format and convert it to |
1616 * |
|
1617 * Take a 32-bit unsigned value in bigendian format and convert it to |
1601 * the platform's native byte order. |
1618 * the platform's native byte order. |
1602 * |
1619 * |
1603 * \param val value to convert |
1620 * \param val value to convert |
1604 * \return converted value. |
1621 * \return converted value. |
1605 */ |
1622 */ |
1606 PHYSFS_DECL PHYSFS_sint32 PHYSFS_swapSBE32(PHYSFS_sint32 val); |
1623 PHYSFS_DECL PHYSFS_uint32 PHYSFS_swapUBE32(PHYSFS_uint32 val); |
1607 |
1624 |
1608 |
1625 |
1609 /** |
1626 /** |
1610 * \fn PHYSFS_uint32 PHYSFS_swapUBE32(PHYSFS_uint32 val) |
1627 * \fn PHYSFS_sint64 PHYSFS_swapSBE64(PHYSFS_sint64 val) |
1611 * \brief Swap bigendian unsigned 32 to platform's native byte order. |
1628 * \brief Swap bigendian signed 64 to platform's native byte order. |
1612 * |
1629 * |
1613 * Take a 32-bit unsigned value in bigendian format and convert it to |
1630 * Take a 64-bit signed value in bigendian format and convert it to |
1614 * the platform's native byte order. |
1631 * the platform's native byte order. |
1615 * |
1632 * |
1616 * \param val value to convert |
1633 * \param val value to convert |
1617 * \return converted value. |
1634 * \return converted value. |
1618 */ |
1635 * |
1619 PHYSFS_DECL PHYSFS_uint32 PHYSFS_swapUBE32(PHYSFS_uint32 val); |
1636 * \warning Remember, PHYSFS_sint64 is only 32 bits on platforms without |
1620 |
|
1621 |
|
1622 /** |
|
1623 * \fn PHYSFS_sint64 PHYSFS_swapSBE64(PHYSFS_sint64 val) |
|
1624 * \brief Swap bigendian signed 64 to platform's native byte order. |
|
1625 * |
|
1626 * Take a 64-bit signed value in bigendian format and convert it to |
|
1627 * the platform's native byte order. |
|
1628 * |
|
1629 * \param val value to convert |
|
1630 * \return converted value. |
|
1631 * |
|
1632 * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without |
|
1633 * any sort of 64-bit support. |
1637 * any sort of 64-bit support. |
1634 */ |
1638 */ |
1635 PHYSFS_DECL PHYSFS_sint64 PHYSFS_swapSBE64(PHYSFS_sint64 val); |
1639 PHYSFS_DECL PHYSFS_sint64 PHYSFS_swapSBE64(PHYSFS_sint64 val); |
1636 |
1640 |
1637 |
1641 |
3131 PHYSFS_ERR_UNSUPPORTED, /**< Operation or feature unsupported. */ |
3135 PHYSFS_ERR_UNSUPPORTED, /**< Operation or feature unsupported. */ |
3132 PHYSFS_ERR_PAST_EOF, /**< Attempted to access past end of file. */ |
3136 PHYSFS_ERR_PAST_EOF, /**< Attempted to access past end of file. */ |
3133 PHYSFS_ERR_FILES_STILL_OPEN, /**< Files still open. */ |
3137 PHYSFS_ERR_FILES_STILL_OPEN, /**< Files still open. */ |
3134 PHYSFS_ERR_INVALID_ARGUMENT, /**< Bad parameter passed to an function. */ |
3138 PHYSFS_ERR_INVALID_ARGUMENT, /**< Bad parameter passed to an function. */ |
3135 PHYSFS_ERR_NOT_MOUNTED, /**< Requested archive/dir not mounted. */ |
3139 PHYSFS_ERR_NOT_MOUNTED, /**< Requested archive/dir not mounted. */ |
3136 PHYSFS_ERR_NO_SUCH_PATH, /**< No such file, directory, or parent. */ |
3140 PHYSFS_ERR_NOT_FOUND, /**< File (or whatever) not found. */ |
3137 PHYSFS_ERR_SYMLINK_FORBIDDEN,/**< Symlink seen when not permitted. */ |
3141 PHYSFS_ERR_SYMLINK_FORBIDDEN,/**< Symlink seen when not permitted. */ |
3138 PHYSFS_ERR_NO_WRITE_DIR, /**< No write dir has been specified. */ |
3142 PHYSFS_ERR_NO_WRITE_DIR, /**< No write dir has been specified. */ |
3139 PHYSFS_ERR_OPEN_FOR_READING, /**< Wrote to a file opened for reading. */ |
3143 PHYSFS_ERR_OPEN_FOR_READING, /**< Wrote to a file opened for reading. */ |
3140 PHYSFS_ERR_OPEN_FOR_WRITING, /**< Read from a file opened for writing. */ |
3144 PHYSFS_ERR_OPEN_FOR_WRITING, /**< Read from a file opened for writing. */ |
3141 PHYSFS_ERR_NOT_A_FILE, /**< Needed a file, got a directory (etc). */ |
3145 PHYSFS_ERR_NOT_A_FILE, /**< Needed a file, got a directory (etc). */ |
3309 * \sa PHYSFS_getUserDir |
3315 * \sa PHYSFS_getUserDir |
3310 */ |
3316 */ |
3311 PHYSFS_DECL const char *PHYSFS_getPrefDir(const char *org, const char *app); |
3317 PHYSFS_DECL const char *PHYSFS_getPrefDir(const char *org, const char *app); |
3312 |
3318 |
3313 |
3319 |
|
3320 /** |
|
3321 * \struct PHYSFS_Archiver |
|
3322 * \brief Abstract interface to provide support for user-defined archives. |
|
3323 * |
|
3324 * \warning This is advanced, hardcore stuff. You don't need this unless you |
|
3325 * really know what you're doing. Most apps will not need this. |
|
3326 * |
|
3327 * Historically, PhysicsFS provided a means to mount various archive file |
|
3328 * formats, and physical directories in the native filesystem. However, |
|
3329 * applications have been limited to the file formats provided by the |
|
3330 * library. This interface allows an application to provide their own |
|
3331 * archive file types. |
|
3332 * |
|
3333 * Conceptually, a PHYSFS_Archiver provides directory entries, while |
|
3334 * PHYSFS_Io provides data streams for those directory entries. The most |
|
3335 * obvious use of PHYSFS_Archiver is to provide support for an archive |
|
3336 * file type that isn't provided by PhysicsFS directly: perhaps some |
|
3337 * proprietary format that only your application needs to understand. |
|
3338 * |
|
3339 * Internally, all the built-in archive support uses this interface, so the |
|
3340 * best examples for building a PHYSFS_Archiver is the source code to |
|
3341 * PhysicsFS itself. |
|
3342 * |
|
3343 * An archiver is added to the system with PHYSFS_registerArchiver(), and then |
|
3344 * it will be available for use automatically with PHYSFS_mount(); if a |
|
3345 * given archive can be handled with your archiver, it will be given control |
|
3346 * as appropriate. |
|
3347 * |
|
3348 * These methods deal with dir handles. You have one instance of your |
|
3349 * archiver, and it generates a unique, opaque handle for each opened |
|
3350 * archive in its openArchive() method. Since the lifetime of an Archiver |
|
3351 * (not an archive) is generally the entire lifetime of the process, and it's |
|
3352 * assumed to be a singleton, we do not provide any instance data for the |
|
3353 * archiver itself; the app can just use some static variables if necessary. |
|
3354 * |
|
3355 * Symlinks should always be followed (except in stat()); PhysicsFS will |
|
3356 * use the stat() method to check for symlinks and make a judgement on |
|
3357 * whether to continue to call other methods based on that. |
|
3358 * |
|
3359 * Archivers, when necessary, should set the PhysicsFS error state with |
|
3360 * PHYSFS_setErrorCode() before returning. PhysicsFS will pass these errors |
|
3361 * back to the application unmolested in most cases. |
|
3362 * |
|
3363 * Thread safety: TO BE DECIDED. !!! FIXME |
|
3364 * |
|
3365 * \sa PHYSFS_registerArchiver |
|
3366 * \sa PHYSFS_deregisterArchiver |
|
3367 * \sa PHYSFS_supportedArchiveTypes |
|
3368 */ |
|
3369 typedef struct PHYSFS_Archiver |
|
3370 { |
|
3371 |
|
3372 // !!! FIXME: split read/write interfaces? |
|
3373 |
|
3374 /** |
|
3375 * \brief Binary compatibility information. |
|
3376 * |
|
3377 * This must be set to zero at this time. Future versions of this |
|
3378 * struct will increment this field, so we know what a given |
|
3379 * implementation supports. We'll presumably keep supporting older |
|
3380 * versions as we offer new features, though. |
|
3381 */ |
|
3382 PHYSFS_uint32 version; |
|
3383 |
|
3384 /** |
|
3385 * \brief Basic info about this archiver. |
|
3386 * |
|
3387 * This is used to identify your archive, and is returned in |
|
3388 * PHYSFS_supportedArchiveTypes(). |
|
3389 */ |
|
3390 PHYSFS_ArchiveInfo info; |
|
3391 |
|
3392 // !!! FIXME: documentation: \brief? |
|
3393 /** |
|
3394 * \brief |
|
3395 * |
|
3396 * Open an archive provided by (io). |
|
3397 * (name) is a filename associated with (io), but doesn't necessarily |
|
3398 * map to anything, let alone a real filename. This possibly- |
|
3399 * meaningless name is in platform-dependent notation. |
|
3400 * (forWrite) is non-zero if this is to be used for |
|
3401 * the write directory, and zero if this is to be used for an |
|
3402 * element of the search path. |
|
3403 * Return NULL on failure. We ignore any error code you set here; |
|
3404 * when PHYSFS_mount() returns, the error will be PHYSFS_ERR_UNSUPPORTED |
|
3405 * (no Archivers could handle this data). // !!! FIXME: yeah? |
|
3406 * Returns non-NULL on success. The pointer returned will be |
|
3407 * passed as the "opaque" parameter for later calls. |
|
3408 */ |
|
3409 void *(*openArchive)(PHYSFS_Io *io, const char *name, int forWrite); |
|
3410 |
|
3411 /** |
|
3412 * List all files in (dirname). Each file is passed to (cb), |
|
3413 * where a copy is made if appropriate, so you should dispose of |
|
3414 * it properly upon return from the callback. |
|
3415 * If you have a failure, report as much as you can. |
|
3416 * (dirname) is in platform-independent notation. |
|
3417 */ |
|
3418 void (*enumerateFiles)(void *opaque, const char *dirname, |
|
3419 PHYSFS_EnumFilesCallback cb, |
|
3420 const char *origdir, void *callbackdata); |
|
3421 |
|
3422 /** |
|
3423 * Open file for reading. |
|
3424 * This filename, (fnm), is in platform-independent notation. |
|
3425 * If you can't handle multiple opens of the same file, |
|
3426 * you can opt to fail for the second call. |
|
3427 * Fail if the file does not exist. |
|
3428 * Returns NULL on failure, and calls PHYSFS_setErrorCode(). |
|
3429 * Returns non-NULL on success. The pointer returned will be |
|
3430 * passed as the "opaque" parameter for later file calls. |
|
3431 */ |
|
3432 PHYSFS_Io *(*openRead)(void *opaque, const char *fnm); |
|
3433 |
|
3434 /** |
|
3435 * Open file for writing. |
|
3436 * If the file does not exist, it should be created. If it exists, |
|
3437 * it should be truncated to zero bytes. The writing |
|
3438 * offset should be the start of the file. |
|
3439 * This filename is in platform-independent notation. |
|
3440 * If you can't handle multiple opens of the same file, |
|
3441 * you can opt to fail for the second call. |
|
3442 * Returns NULL on failure, and calls PHYSFS_setErrorCode(). |
|
3443 * Returns non-NULL on success. The pointer returned will be |
|
3444 * passed as the "opaque" parameter for later file calls. |
|
3445 */ |
|
3446 PHYSFS_Io *(*openWrite)(void *opaque, const char *filename); |
|
3447 |
|
3448 /** |
|
3449 * Open file for appending. |
|
3450 * If the file does not exist, it should be created. The writing |
|
3451 * offset should be the end of the file. |
|
3452 * This filename is in platform-independent notation. |
|
3453 * If you can't handle multiple opens of the same file, |
|
3454 * you can opt to fail for the second call. |
|
3455 * Returns NULL on failure, and calls PHYSFS_setErrorCode(). |
|
3456 * Returns non-NULL on success. The pointer returned will be |
|
3457 * passed as the "opaque" parameter for later file calls. |
|
3458 */ |
|
3459 PHYSFS_Io *(*openAppend)(void *opaque, const char *filename); |
|
3460 |
|
3461 /** |
|
3462 * Delete a file in the archive/directory. |
|
3463 * Return non-zero on success, zero on failure. |
|
3464 * This filename is in platform-independent notation. |
|
3465 * This method may be NULL. |
|
3466 * On failure, call PHYSFS_setErrorCode(). |
|
3467 */ |
|
3468 int (*remove)(void *opaque, const char *filename); |
|
3469 |
|
3470 /** |
|
3471 * Create a directory in the archive/directory. |
|
3472 * If the application is trying to make multiple dirs, PhysicsFS |
|
3473 * will split them up into multiple calls before passing them to |
|
3474 * your driver. |
|
3475 * Return non-zero on success, zero on failure. |
|
3476 * This filename is in platform-independent notation. |
|
3477 * This method may be NULL. |
|
3478 * On failure, call PHYSFS_setErrorCode(). |
|
3479 */ |
|
3480 int (*mkdir)(void *opaque, const char *filename); |
|
3481 |
|
3482 /** |
|
3483 * Obtain basic file metadata. |
|
3484 * Returns non-zero on success, zero on failure. |
|
3485 * On failure, call PHYSFS_setErrorCode(). |
|
3486 */ |
|
3487 int (*stat)(void *opaque, const char *fn, PHYSFS_Stat *stat); |
|
3488 |
|
3489 /** |
|
3490 * Close directories/archives, and free any associated memory, |
|
3491 * including the original PHYSFS_Io and (opaque) itself, if |
|
3492 * applicable. Implementation can assume that it won't be called if |
|
3493 * there are still files open from this archive. |
|
3494 */ |
|
3495 void (*closeArchive)(void *opaque); |
|
3496 } PHYSFS_Archiver; |
|
3497 |
|
3498 /** |
|
3499 * \fn int PHYSFS_registerArchiver(const PHYSFS_Archiver *archiver) |
|
3500 * \brief Add a new archiver to the system. |
|
3501 * |
|
3502 * !!! FIXME: write me. |
|
3503 * |
|
3504 * You may not have two archivers that handle the same extension. If you are |
|
3505 * going to have a clash, you can deregister the other archiver (including |
|
3506 * built-in ones) with PHYSFS_deregisterArchiver(). |
|
3507 * |
|
3508 * The data in (archiver) is copied; you may free this pointer when this |
|
3509 * function returns. |
|
3510 * |
|
3511 * \param archiver The archiver to register. |
|
3512 * \return Zero on error, non-zero on success. |
|
3513 * |
|
3514 * \sa PHYSFS_Archiver |
|
3515 * \sa PHYSFS_deregisterArchiver |
|
3516 */ |
|
3517 PHYSFS_DECL int PHYSFS_registerArchiver(const PHYSFS_Archiver *archiver); |
|
3518 |
|
3519 /** |
|
3520 * \fn int PHYSFS_deregisterArchiver(const char *ext) |
|
3521 * \brief Remove an archiver from the system. |
|
3522 * |
|
3523 * !!! FIXME: write me. |
|
3524 * |
|
3525 * This fails if there are any archives still open that use this archiver. |
|
3526 * |
|
3527 * \param ext Filename extension that the archiver handles. |
|
3528 * \return Zero on error, non-zero on success. |
|
3529 * |
|
3530 * \sa PHYSFS_Archiver |
|
3531 * \sa PHYSFS_registerArchiver |
|
3532 */ |
|
3533 PHYSFS_DECL int PHYSFS_deregisterArchiver(const char *ext); |
|
3534 |
|
3535 |
3314 /* Everything above this line is part of the PhysicsFS 2.1 API. */ |
3536 /* Everything above this line is part of the PhysicsFS 2.1 API. */ |
3315 |
|
3316 |
3537 |
3317 #ifdef __cplusplus |
3538 #ifdef __cplusplus |
3318 } |
3539 } |
3319 #endif |
3540 #endif |
3320 |
3541 |