PHP 8.4.0 RC4 available for testing

svn_ls

(PECL svn >= 0.1.0)

svn_lsReturns list of directory contents in repository URL, optionally at revision number

説明

svn_ls(
    string $repos_url,
    int $revision_no = SVN_REVISION_HEAD,
    bool $recurse = false,
    bool $peg = false
): array

This function queries the repository URL and returns a list of files and directories, optionally from a specific revision. This is equivalent to svn list $repos_url[@$revision_no]

注意:

This function does not work with working copies. repos_url must be a repository URL.

パラメータ

url

URL of the repository, eg. http://www.example.com/svnroot. To access a local Subversion repository via filesystem, use the file URI scheme, eg. file:///home/user/svn-repos

revision

Integer revision number to retrieve listing of. When omitted, the HEAD revision is used.

recurse

Enables recursion.

戻り値

On success, this function returns an array file listing in the format of:

[0] => Array
    (
        [created_rev] => integer revision number of last edit
        [last_author] => string author name of last edit
        [size] => integer byte file size of file
        [time] => string date of last edit in form 'M d H:i'
                  or 'M d Y', depending on how old the file is
        [time_t] => integer unix timestamp of last edit
        [name] => name of file/directory
        [type] => type, can be 'file' or 'dir'
    )
[1] => ...

例1 svn_ls() example

<?php
print_r
( svn_ls('http://www.example.com/svnroot/') );
?>

上の例の出力は、 たとえば以下のようになります。

Array
(
    [0] => Array
        (
            [created_rev] => 20
            [last_author] => Joe
            [size] => 0
            [time] => Apr 02 09:28
            [time_t] => 1175520529
            [name] => tags
            [type] => dir
        )
    [1] => Array
        (
            [created_rev] => 23
            [last_author] => Bob
            [size] => 0
            [time] => Apr 02 15:15
            [time_t] => 1175541322
            [name] => trunk
            [type] => dir
        )
)

注意

警告

この関数は、 実験的 なものです。この関数の動作・ 名前・その他ドキュメントに書かれている事項は、予告なく、将来的な PHP のリリースにおいて変更される可能性があります。 この関数は自己責任で使用してください。

add a note

User Contributed Notes 1 note

up
0
php thereatthe bluedream dotty tv
12 years ago
Be aware that the function will condition the path for you; do not do it yourself or you will have resulting errors.

Ex: that paths with spaces in them do NOT need the escaping slash
<?php
svn_ls
('file:///var/svn/myrepo/dirA/another dir'); //will work->happiness
svn_ls('file:///var/svn/myrepo/dirA/another\ dir'); //will fail
?>
Warning: svn_ls(): svn error(s) occured 160013 (Filesystem has no item) URL 'file:///var/svn/myrepo/dirA/another\ dir' non-existent in that revision in file.php on line 42
To Top