Alien-PhysFS

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

`getDirSeparator()` returns the native separator for the current platform; virtual paths always use `/`.

## Functions that shadow Perl builtins

Several PhysicsFS names are also Perl builtins (`close`, `delete`, `exists`, `mkdir`, `seek`, and `stat`).
Importing them with `:all` does not override the builtin when you call a bare word such as `exists($path)`. Call the
PhysicsFS version fully qualified:

```
Game::PhysicsFS::exists('/game/player.png');
Game::PhysicsFS::stat('/game/player.png', \%info);
Game::PhysicsFS::close($handle);
```

Conversely, call Perl's builtin explicitly when you need it:

```
CORE::close($fh);
```

## Features

README.md  view on Meta::CPAN


#### `getDirSeparator( )`

Return the platform's native directory separator string: `\` on Windows, `/` on Unix, and `:` on classic Mac OS. It
may be more than one character. This is only for constructing native search and write paths; virtual filesystem paths
always use `/`.

#### `permitSymbolicLinks( $allow )`

Enable or disable following symbolic links inside the virtual filesystem. Symlinks are denied by default because a link
could escape the search or write paths. `$allow` is any boolean. Calling this after `init()` is safe. `stat()` never
follows a symlink; if links are denied, `stat()` treats a symlink as nonexistent.

#### `symbolicLinksPermitted( )`

Return non-zero if symbolic links are currently permitted, zero otherwise. Defaults to false after initialization.

#### `setRoot( $archive, $subdir )`

Make a subdirectory of a mounted archive or directory its virtual root. For example, if `x.zip` contains `y/z.txt`
and is mounted at `/a`, then `setRoot( 'x.zip', '/y' )` makes `/a/z.txt` resolve to that file. `$archive` is the
platform-dependent path originally mounted; `$subdir` is a platform-independent virtual path. Pass `undef` or `/` to

README.md  view on Meta::CPAN


- `filetype`

    One of the `FILETYPE_*` values.

- `readonly`

    Non-zero when the archive considers the entry read-only. This is an estimate: an overlapping write directory can still
    make the path writable by creating it elsewhere.

#### `stat( $filename, \%info )`

Fill `%info` with metadata for a platform-independent path. Returns non-zero on success; on failure the hash contents
are undefined. This function never follows symlinks: if links are denied, a symlink is treated as nonexistent; if links
are permitted, the link itself is described.

#### `GetStat( $filename )`

Perl helper around `stat( )`. Returns a hash reference with the fields described under `Stat`, or `undef` on
failure.

# SEE ALSO

[Affix](https://metacpan.org/pod/Affix), [Alien::PhysFS](https://metacpan.org/pod/Alien%3A%3APhysFS), [https://icculus.org/physfs/](https://icculus.org/physfs/), [https://icculus.org/physfs/docs/html/physfs\_8h.html](https://icculus.org/physfs/docs/h...

# AUTHOR

Sanko Robinson - [https://github.com/sanko/](https://github.com/sanko/)

lib/Game/PhysicsFS.pm  view on Meta::CPAN

I<platform-independent> notation: forward slashes, no drive letters, and no leading separator is required.
C<getDirSeparator()> returns the native separator for the current platform; virtual paths always use C</>.

=head2 Functions that shadow Perl builtins

Several PhysicsFS names are also Perl builtins (C<close>, C<delete>, C<exists>, C<mkdir>, C<seek>, and C<stat>).
Importing them with C<:all> does not override the builtin when you call a bare word such as C<exists($path)>. Call the
PhysicsFS version fully qualified:

    Game::PhysicsFS::exists('/game/player.png');
    Game::PhysicsFS::stat('/game/player.png', \%info);
    Game::PhysicsFS::close($handle);

Conversely, call Perl's builtin explicitly when you need it:

    CORE::close($fh);

=head2 Features

Each feature below is an Exporter tag. C<:all> is the default catch-all.

lib/Game/PhysicsFS.pm  view on Meta::CPAN

=cut

    sub _all () {
        state $done++ && return;
        _version();
        _init();
        _error();
        _mount();
        _files();
        _list();
        _stat();
    }

=head3 C<:version> - Version information

=head4 C<Version>

The underlying struct exposed as a hash reference with C<major>, C<minor>, and C<patch> keys. Upstream defines these as
unsigned 8-bit fields: C<major> revision, C<minor> revision, and C<patch>level.

=head4 C<getLinkedVersion( $version )>

lib/Game/PhysicsFS.pm  view on Meta::CPAN


=head4 C<getDirSeparator( )>

Return the platform's native directory separator string: C<\> on Windows, C</> on Unix, and C<:> on classic Mac OS. It
may be more than one character. This is only for constructing native search and write paths; virtual filesystem paths
always use C</>.

=head4 C<permitSymbolicLinks( $allow )>

Enable or disable following symbolic links inside the virtual filesystem. Symlinks are denied by default because a link
could escape the search or write paths. C<$allow> is any boolean. Calling this after C<init()> is safe. C<stat()> never
follows a symlink; if links are denied, C<stat()> treats a symlink as nonexistent.

=head4 C<symbolicLinksPermitted( )>

Return non-zero if symbolic links are currently permitted, zero otherwise. Defaults to false after initialization.

=head4 C<setRoot( $archive, $subdir )>

Make a subdirectory of a mounted archive or directory its virtual root. For example, if C<x.zip> contains C<y/z.txt>
and is mounted at C</a>, then C<setRoot( 'x.zip', '/y' )> makes C</a/z.txt> resolve to that file. C<$archive> is the
platform-dependent path originally mounted; C<$subdir> is a platform-independent virtual path. Pass C<undef> or C</> to

lib/Game/PhysicsFS.pm  view on Meta::CPAN


One of the C<FILETYPE_*> values.

=item C<readonly>

Non-zero when the archive considers the entry read-only. This is an estimate: an overlapping write directory can still
make the path writable by creating it elsewhere.

=back

=head4 C<stat( $filename, \%info )>

Fill C<%info> with metadata for a platform-independent path. Returns non-zero on success; on failure the hash contents
are undefined. This function never follows symlinks: if links are denied, a symlink is treated as nonexistent; if links
are permitted, the link itself is described.

=head4 C<GetStat( $filename )>

Perl helper around C<stat( )>. Returns a hash reference with the fields described under C<Stat>, or C<undef> on
failure.

=cut

    sub _stat () {
        state $done++ && return;
        _enum_and_export FileType => [qw[FILETYPE_REGULAR FILETYPE_DIRECTORY FILETYPE_SYMLINK FILETYPE_OTHER]];
        _typedef_and_export Stat =>
            Struct [ filesize => Int64, modtime => Int64, createtime => Int64, accesstime => Int64, filetype => FileType(), readonly => Int ];
        _affix_and_export stat => [ String, Pointer [ Stat() ] ], Bool;
        _func_and_export GetStat => sub ($filename) {
            my %stat;
            return undef unless Game::PhysicsFS::stat( $filename, \%stat );
            return \%stat;
        };
    }

=head1 SEE ALSO

L<Affix>, L<Alien::PhysFS>, L<https://icculus.org/physfs/>, L<https://icculus.org/physfs/docs/html/physfs_8h.html>

=head1 AUTHOR



( run in 1.701 second using v1.01-cache-2.11-cpan-eb134014566 )