mirror of
https://github.com/php-win-ext/php-rar.git
synced 2026-03-24 13:02:06 +01:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10932c2450 | ||
|
|
b79f595379 | ||
|
|
479372f714 | ||
|
|
121310f696 | ||
|
|
43589ad851 |
18
composer.json
Normal file
18
composer.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "rar",
|
||||
"type": "extension",
|
||||
"license": [
|
||||
"PHP License"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Gustavo Lopes",
|
||||
"email": "cataphract@php.net"
|
||||
},
|
||||
{
|
||||
"name": "Antony Dovgal",
|
||||
"email": "tony@daylessday.org"
|
||||
}
|
||||
],
|
||||
"description": "rar extension"
|
||||
}
|
||||
@@ -37,6 +37,6 @@ if test "$PHP_RAR" != "no"; then
|
||||
PHP_REQUIRE_CXX()
|
||||
PHP_ADD_LIBRARY_WITH_PATH(stdc++, "", RAR_SHARED_LIBADD)
|
||||
|
||||
PHP_NEW_EXTENSION(rar, rar.c rar_error.c rararch.c rarentry.c rar_stream.c rar_navigation.c $unrar_sources, $ext_shared,,-DRARDLL -DSILENT -Wno-write-strings -Wall -I@ext_srcdir@/unrar)
|
||||
PHP_NEW_EXTENSION(rar, rar.c rar_error.c rararch.c rarentry.c rar_stream.c rar_navigation.c rar_time.c $unrar_sources, $ext_shared,,-DRARDLL -DSILENT -Wno-write-strings -Wall -I@ext_srcdir@/unrar)
|
||||
PHP_ADD_BUILD_DIR($ext_builddir/unrar)
|
||||
fi
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
ARG_ENABLE("rar", "Rar support", "no");
|
||||
|
||||
if (PHP_RAR != "no") {
|
||||
EXTENSION("rar", "rar.c rar_error.c rararch.c rarentry.c rar_stream.c rar_navigation.c", PHP_RAR_SHARED, "/DRARDLL /DSILENT /EHsc /D_WSTDIO_DEFINED");
|
||||
EXTENSION("rar", "rar.c rar_error.c rararch.c rarentry.c rar_stream.c rar_navigation.c rar_time.c", PHP_RAR_SHARED, "/DRARDLL /DSILENT /EHsc /D_WSTDIO_DEFINED");
|
||||
ADD_SOURCES(configure_module_dirname + "/unrar",
|
||||
"sha256.cpp qopen.cpp \
|
||||
blake2s.cpp recvol.cpp \
|
||||
|
||||
95
package.xml
95
package.xml
@@ -23,11 +23,11 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<active>no</active>
|
||||
</developer>
|
||||
|
||||
<date>2013-10-11</date>
|
||||
<time>13:00:00</time>
|
||||
<date>2017-07-22</date>
|
||||
<time>03:00:00</time>
|
||||
<version>
|
||||
<release>3.0.2</release>
|
||||
<api>3.0.0</api>
|
||||
<release>4.0.0</release>
|
||||
<api>4.0.0</api>
|
||||
</version>
|
||||
|
||||
<stability>
|
||||
@@ -36,8 +36,11 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||
</stability>
|
||||
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>- Fixed build with PHP 5.5.
|
||||
- Upgraded bundled unrar to version 4.2.4.
|
||||
<notes>- Merge changes made to unrar up to version 5.5.6.
|
||||
- Support PHP 7.0 and PHP 7.1.
|
||||
- Added functions RarEntry::getRedirType(), RarEntry::isRedirectToDirectory() and RarEntry::getRedirTarget(), as well as the following constants on RarEntry: FSREDIR_UNIXSYMLINK, FSREDIR_WINSYMLINK, FSREDIR_JUNCTION, FSREDIR_HARDLINK and FSREDIR_FILECOPY.
|
||||
- Changed stat handler to return UTC time for creation, modification and access time (does not work reliably on Windows).
|
||||
- Fix cloning of RarArchive being allowed.
|
||||
</notes>
|
||||
<contents>
|
||||
<dir name="/">
|
||||
@@ -142,6 +145,20 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<file role="test" name="097.phpt"/>
|
||||
<file role="test" name="098.phpt"/>
|
||||
<file role="test" name="099.phpt"/>
|
||||
<file role="test" name="100.phpt"/>
|
||||
<file role="test" name="101.phpt"/>
|
||||
<file role="test" name="102.phpt"/>
|
||||
<file role="test" name="103.phpt"/>
|
||||
<file role="test" name="104.phpt"/>
|
||||
<file role="test" name="105.phpt"/>
|
||||
<file role="test" name="106.phpt"/>
|
||||
<file role="test" name="107.phpt"/>
|
||||
<file role="test" name="108.phpt"/>
|
||||
<file role="test" name="109.phpt"/>
|
||||
<file role="test" name="110.phpt"/>
|
||||
<file role="test" name="111.phpt"/>
|
||||
<file role="test" name="112.phpt"/>
|
||||
<file role="test" name="113.phpt"/>
|
||||
<file role="test" name="commented.rar"/>
|
||||
<file role="test" name="corrupted.rar"/>
|
||||
<file role="test" name="directories.rar"/>
|
||||
@@ -165,6 +182,9 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<file role="test" name="solid.rar"/>
|
||||
<file role="test" name="sparsefiles_rar.rar"/>
|
||||
<file role="test" name="store_method.rar"/>
|
||||
<file role="test" name="rar5-links.rar"/>
|
||||
<file role="test" name="rar5_multi.part1.rar"/>
|
||||
<file role="test" name="rar5_multi.part2.rar"/>
|
||||
</dir> <!-- /tests -->
|
||||
<dir name="unrar">
|
||||
<file name="acknow.txt" role="doc" />
|
||||
@@ -173,7 +193,10 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<file name="archive.hpp" role="src" />
|
||||
<file name="arcread.cpp" role="src" />
|
||||
<file name="array.hpp" role="src" />
|
||||
<file name="beosea.cpp" role="src" />
|
||||
<file name="blake2s.cpp" role="src" />
|
||||
<file name="blake2s.hpp" role="src" />
|
||||
<file name="blake2s_sse.cpp" role="src" />
|
||||
<file name="blake2sp.cpp" role="src" />
|
||||
<file name="cmddata.cpp" role="src" />
|
||||
<file name="cmddata.hpp" role="src" />
|
||||
<file name="coder.cpp" role="src" />
|
||||
@@ -185,6 +208,10 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<file name="crc.hpp" role="src" />
|
||||
<file name="crypt.cpp" role="src" />
|
||||
<file name="crypt.hpp" role="src" />
|
||||
<file name="crypt1.cpp" role="src" />
|
||||
<file name="crypt2.cpp" role="src" />
|
||||
<file name="crypt3.cpp" role="src" />
|
||||
<file name="crypt5.cpp" role="src" />
|
||||
<file name="dll.cpp" role="src" />
|
||||
<file name="dll.hpp" role="src" />
|
||||
<file name="encname.cpp" role="src" />
|
||||
@@ -210,7 +237,12 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<file name="getbits.hpp" role="src" />
|
||||
<file name="global.cpp" role="src" />
|
||||
<file name="global.hpp" role="src" />
|
||||
<file name="hardlinks.cpp" role="src" />
|
||||
<file name="hash.cpp" role="src" />
|
||||
<file name="hash.hpp" role="src" />
|
||||
<file name="headers.cpp" role="src" />
|
||||
<file name="headers.hpp" role="src" />
|
||||
<file name="headers5.hpp" role="src" />
|
||||
<file name="isnt.cpp" role="src" />
|
||||
<file name="isnt.hpp" role="src" />
|
||||
<file name="LICENSE.txt" role="doc" />
|
||||
@@ -226,9 +258,10 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<file name="options.cpp" role="src" />
|
||||
<file name="options.hpp" role="src" />
|
||||
<file name="os.hpp" role="src" />
|
||||
<file name="os2ea.cpp" role="src" />
|
||||
<file name="pathfn.cpp" role="src" />
|
||||
<file name="pathfn.hpp" role="src" />
|
||||
<file name="qopen.cpp" role="src" />
|
||||
<file name="qopen.hpp" role="src" />
|
||||
<file name="rar.cpp" role="src" />
|
||||
<file name="rar.hpp" role="src" />
|
||||
<file name="rardefs.hpp" role="src" />
|
||||
@@ -238,10 +271,31 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<file name="rarvm.cpp" role="src" />
|
||||
<file name="rarvm.hpp" role="src" />
|
||||
<file name="rarvmtbl.cpp" role="src" />
|
||||
<file name="rawint.hpp" role="src" />
|
||||
<file name="rawread.cpp" role="src" />
|
||||
<file name="rawread.hpp" role="src" />
|
||||
<file name="rdwrfn.cpp" role="src" />
|
||||
<file name="rdwrfn.hpp" role="src" />
|
||||
<file name="recvol3.cpp" role="src" />
|
||||
<file name="recvol5.cpp" role="src" />
|
||||
<file name="rs16.cpp" role="src" />
|
||||
<file name="rs16.hpp" role="src" />
|
||||
<file name="sha256.cpp" role="src" />
|
||||
<file name="sha256.hpp" role="src" />
|
||||
<file name="threadmisc.cpp" role="src" />
|
||||
<file name="threadpool.cpp" role="src" />
|
||||
<file name="threadpool.hpp" role="src" />
|
||||
<file name="ui.cpp" role="src" />
|
||||
<file name="ui.hpp" role="src" />
|
||||
<file name="uicommon.cpp" role="src" />
|
||||
<file name="uiconsole.cpp" role="src" />
|
||||
<file name="uisilent.cpp" role="src" />
|
||||
<file name="unpack30.cpp" role="src" />
|
||||
<file name="unpack50.cpp" role="src" />
|
||||
<file name="unpack50frag.cpp" role="src" />
|
||||
<file name="unpack50mt.cpp" role="src" />
|
||||
<file name="unpackinline.cpp" role="src" />
|
||||
<file name="win32lnk.cpp" role="src" />
|
||||
<file name="README.txt" role="doc" />
|
||||
<file name="recvol.cpp" role="src" />
|
||||
<file name="recvol.hpp" role="src" />
|
||||
@@ -251,7 +305,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<file name="rijndael.hpp" role="src" />
|
||||
<file name="rs.cpp" role="src" />
|
||||
<file name="rs.hpp" role="src" />
|
||||
<file name="savepos.cpp" role="src" />
|
||||
<file name="savepos.hpp" role="src" />
|
||||
<file name="scantree.cpp" role="src" />
|
||||
<file name="scantree.hpp" role="src" />
|
||||
@@ -275,7 +328,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<file name="ulinks.hpp" role="src" />
|
||||
<file name="unicode.cpp" role="src" />
|
||||
<file name="unicode.hpp" role="src" />
|
||||
<file name="unios2.cpp" role="src" />
|
||||
<file name="unpack.cpp" role="src" />
|
||||
<file name="unpack.hpp" role="src" />
|
||||
<file name="unpack15.cpp" role="src" />
|
||||
@@ -291,7 +343,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<file name="config.w32" role="src" />
|
||||
<file name="CREDITS" role="doc" />
|
||||
<file name="LICENSE" role="doc" />
|
||||
<file name="README" role="doc" />
|
||||
<file name="README.md" role="doc" />
|
||||
<file name="example.php" role="doc" />
|
||||
<file name="php_rar.h" role="src" />
|
||||
<file name="rar.c" role="src" />
|
||||
@@ -299,6 +351,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<file name="rararch.c" role="src" />
|
||||
<file name="rarentry.c" role="src" />
|
||||
<file name="rar_error.c" role="src" />
|
||||
<file name="rar_time.c" role="src" />
|
||||
<file role="src" name="rar_navigation.c"/>
|
||||
</dir> <!-- / -->
|
||||
</contents>
|
||||
@@ -306,7 +359,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<dependencies>
|
||||
<required>
|
||||
<php>
|
||||
<min>5.2.0</min>
|
||||
<min>5.3.0</min>
|
||||
</php>
|
||||
<pearinstaller>
|
||||
<min>1.4.0</min>
|
||||
@@ -319,6 +372,22 @@ http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<extsrcrelease />
|
||||
|
||||
<changelog>
|
||||
<release>
|
||||
<version>
|
||||
<release>3.0.2</release>
|
||||
<api>3.0.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2013-10-11</date>
|
||||
<notes>Changes in this version:
|
||||
- Fixed build with PHP 5.5.
|
||||
- Upgraded bundled unrar to version 4.2.4.
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
<release>
|
||||
<version>
|
||||
<release>3.0.1</release>
|
||||
@@ -406,7 +475,7 @@ Other changes:
|
||||
- A lot of refactoring and compilation as C, not C++.
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
|
||||
<release>
|
||||
<version>
|
||||
<release>1.0.0</release>
|
||||
|
||||
@@ -362,6 +362,12 @@ php_stream *php_stream_rar_open(char *arc_name,
|
||||
STREAMS_DC TSRMLS_DC);
|
||||
extern php_stream_wrapper php_stream_rar_wrapper;
|
||||
|
||||
/* rar_time.c */
|
||||
void rar_time_convert(unsigned low, unsigned high, time_t *to);
|
||||
int rar_dos_time_convert(unsigned dos_time, time_t *to);
|
||||
#ifdef PHP_WIN32
|
||||
#define timegm _mkgmtime
|
||||
#endif
|
||||
#endif /* PHP_RAR_H */
|
||||
|
||||
|
||||
|
||||
@@ -313,6 +313,9 @@ void _rar_delete_entries(rar_file_t *rar TSRMLS_DC)
|
||||
if (rar->entries->entries_array != NULL) {
|
||||
size_t i;
|
||||
for (i = 0; i < rar->entries->num_entries; i++) {
|
||||
if (rar->entries->entries_array[i]->entry.RedirName != NULL) {
|
||||
efree(rar->entries->entries_array[i]->entry.RedirName);
|
||||
}
|
||||
efree(rar->entries->entries_array[i]);
|
||||
}
|
||||
efree(rar->entries->entries_array);
|
||||
@@ -353,7 +356,11 @@ int _rar_list_files(rar_file_t *rar TSRMLS_DC) /* {{{ */
|
||||
ents->last_accessed = NULL;
|
||||
|
||||
while (result == 0) {
|
||||
struct _rar_unique_entry *ue;
|
||||
struct RARHeaderDataEx entry = {0};
|
||||
wchar_t redir_name[1024] = L"";
|
||||
entry.RedirName = redir_name;
|
||||
entry.RedirNameSize = sizeof(redir_name) / sizeof(redir_name[0]);
|
||||
result = RARReadHeaderEx(rar->arch_handle, &entry);
|
||||
/* value of 2nd argument is irrelevant in RAR_OM_LIST_[SPLIT] mode */
|
||||
if (result == 0) {
|
||||
@@ -401,16 +408,22 @@ int _rar_list_files(rar_file_t *rar TSRMLS_DC) /* {{{ */
|
||||
}
|
||||
assert(capacity > ents->num_entries);
|
||||
|
||||
ents->entries_array[ents->num_entries] =
|
||||
ents->entries_array[ents->num_entries] = ue =
|
||||
emalloc(sizeof *ents->entries_array[0]);
|
||||
memcpy(&ents->entries_array[ents->num_entries]->entry, &entry,
|
||||
sizeof ents->entries_array[0]->entry);
|
||||
ents->entries_array[ents->num_entries]->id = ents->num_entries;
|
||||
ents->entries_array[ents->num_entries]->packed_size = packed_size;
|
||||
memcpy(&ue->entry, &entry, sizeof ents->entries_array[0]->entry);
|
||||
ue->id = ents->num_entries;
|
||||
ue->packed_size = packed_size;
|
||||
_rar_nav_get_depth_and_length(entry.FileNameW,
|
||||
sizeof(entry.FileNameW) / sizeof(entry.FileNameW[0]), /* = 1024 */
|
||||
&ents->entries_array[ents->num_entries]->depth,
|
||||
&ents->entries_array[ents->num_entries]->name_wlen TSRMLS_CC);
|
||||
&ue->depth, &ue->name_wlen TSRMLS_CC);
|
||||
if (redir_name[0] != L'\0') {
|
||||
size_t size = (wcslen(redir_name) + 1) * sizeof(redir_name[0]);
|
||||
ue->entry.RedirName = emalloc(size);
|
||||
memcpy(ue->entry.RedirName, redir_name, size);
|
||||
} else {
|
||||
ue->entry.RedirName = NULL;
|
||||
ue->entry.RedirNameSize = 0;
|
||||
}
|
||||
ents->num_entries++;
|
||||
}
|
||||
|
||||
|
||||
56
rar_stream.c
56
rar_stream.c
@@ -41,7 +41,6 @@ extern "C" {
|
||||
#include <wchar.h>
|
||||
|
||||
#include "php_rar.h"
|
||||
#include "unrar/rartypes.hpp"
|
||||
|
||||
#include <php_streams.h>
|
||||
#include <ext/standard/url.h>
|
||||
@@ -280,43 +279,6 @@ static mode_t _rar_convert_file_attrs(unsigned os_attrs,
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void _rar_time_convert(unsigned low, unsigned high, time_t *to) /* {{{ */
|
||||
{
|
||||
time_t default_ = (time_t) 0,
|
||||
local_time;
|
||||
struct tm tm = {0};
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (high == 0U && low == 0U) {
|
||||
*to = default_;
|
||||
return;
|
||||
}
|
||||
|
||||
/* 11644473600000000000 - number of ns between 01-01-1601 and 01-01-1970. */
|
||||
uint64 ushift=INT32TO64(0xA1997B0B,0x4C6A0000);
|
||||
|
||||
/* value is in 10^-7 seconds since 01-01-1601 */
|
||||
/* convert to nanoseconds, shift to 01-01-1970 and convert to seconds */
|
||||
local_time = (time_t) ((INT32TO64(high, low) * 100 - ushift) / 1000000000);
|
||||
|
||||
/* now we have the time in... I don't know what. It gives UTC - tz offset */
|
||||
/* we need to try and convert it to UTC */
|
||||
/* abuse gmtime, which is supposed to work with UTC */
|
||||
#ifndef PHP_WIN32
|
||||
if (gmtime_r(&local_time, &tm) == NULL) {
|
||||
#else
|
||||
if (gmtime_s(&tm, &local_time) != 0) {
|
||||
#endif
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING,
|
||||
"Could not convert time to UTC, using local time");
|
||||
*to = local_time;
|
||||
}
|
||||
|
||||
tm.tm_isdst = -1;
|
||||
*to = local_time + (local_time - mktime(&tm));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static int _rar_stat_from_header(struct RARHeaderDataEx *header,
|
||||
php_stream_statbuf *ssb) /* {{{ */
|
||||
{
|
||||
@@ -346,27 +308,19 @@ static int _rar_stat_from_header(struct RARHeaderDataEx *header,
|
||||
ssb->sb.st_size = (long) (unsigned long) (int64) unp_size;
|
||||
}
|
||||
|
||||
_rar_time_convert(header->AtimeLow, header->AtimeHigh, &ssb->sb.st_atime);
|
||||
_rar_time_convert(header->CtimeLow, header->CtimeHigh, &ssb->sb.st_ctime);
|
||||
rar_time_convert(header->AtimeLow, header->AtimeHigh, &ssb->sb.st_atime);
|
||||
rar_time_convert(header->CtimeLow, header->CtimeHigh, &ssb->sb.st_ctime);
|
||||
|
||||
if (header->MtimeLow == 0 && header->MtimeHigh == 0) {
|
||||
/* high precision mod time undefined */
|
||||
struct tm time_s = {0};
|
||||
time_t time;
|
||||
unsigned dos_time = header->FileTime;
|
||||
|
||||
time_s.tm_sec = (dos_time & 0x1f)*2;
|
||||
time_s.tm_min = (dos_time>>5) & 0x3f;
|
||||
time_s.tm_hour = (dos_time>>11) & 0x1f;
|
||||
time_s.tm_mday = (dos_time>>16) & 0x1f;
|
||||
time_s.tm_mon = ((dos_time>>21) & 0x0f) - 1;
|
||||
time_s.tm_year = (dos_time>>25) + 80;
|
||||
if ((time = mktime(&time_s)) == -1)
|
||||
if (rar_dos_time_convert(header->FileTime, &time) == FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
ssb->sb.st_mtime = time;
|
||||
}
|
||||
else {
|
||||
_rar_time_convert(header->MtimeLow, header->MtimeHigh,
|
||||
rar_time_convert(header->MtimeLow, header->MtimeHigh,
|
||||
&ssb->sb.st_mtime);
|
||||
}
|
||||
|
||||
|
||||
63
rar_time.c
Normal file
63
rar_time.c
Normal file
@@ -0,0 +1,63 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <php.h>
|
||||
#include "php_rar.h"
|
||||
|
||||
void rar_time_convert(unsigned low, unsigned high, time_t *to) /* {{{ */
|
||||
{
|
||||
time_t default_ = (time_t) 0,
|
||||
local_time;
|
||||
struct tm tm = {0};
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (high == 0U && low == 0U) {
|
||||
*to = default_;
|
||||
return;
|
||||
}
|
||||
|
||||
/* 11644473600000000000 - number of ns between 01-01-1601 and 01-01-1970. */
|
||||
uint64 ushift=INT32TO64(0xA1997B0B,0x4C6A0000);
|
||||
|
||||
/* value is in 10^-7 seconds since 01-01-1601 */
|
||||
/* convert to nanoseconds, shift to 01-01-1970 and convert to seconds */
|
||||
local_time = (time_t) ((INT32TO64(high, low) * 100 - ushift) / 1000000000);
|
||||
|
||||
/* now we have the time in... I don't know what. It gives UTC - tz offset */
|
||||
/* we need to try and convert it to UTC */
|
||||
/* abuse gmtime, which is supposed to work with UTC */
|
||||
if (php_gmtime_r(&local_time, &tm) == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING,
|
||||
"Could not convert time to UTC, using local time");
|
||||
*to = local_time;
|
||||
}
|
||||
|
||||
tm.tm_isdst = -1;
|
||||
*to = local_time + (local_time - mktime(&tm));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
int rar_dos_time_convert(unsigned dos_time, time_t *to) /* {{{ */
|
||||
{
|
||||
struct tm time_s = {0};
|
||||
|
||||
time_s.tm_sec = (dos_time & 0x1f)*2;
|
||||
time_s.tm_min = (dos_time>>5) & 0x3f;
|
||||
time_s.tm_hour = (dos_time>>11) & 0x1f;
|
||||
time_s.tm_mday = (dos_time>>16) & 0x1f;
|
||||
time_s.tm_mon = ((dos_time>>21) & 0x0f) - 1;
|
||||
time_s.tm_year = (dos_time>>25) + 80;
|
||||
/* the dos times that unrar gives out seem to be already in UTC.
|
||||
* Or at least they don't depend on TZ */
|
||||
if ((*to = timegm(&time_s)) == (time_t) -1) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
29
rarentry.c
29
rarentry.c
@@ -46,7 +46,7 @@ static int _rar_decl_priv_prop_null(zend_class_entry *ce, const char *name,
|
||||
int name_length, char *doc_comment,
|
||||
int doc_comment_len TSRMLS_DC);
|
||||
static zval *_rar_entry_get_property(zval *entry_obj, char *name, int namelen TSRMLS_DC);
|
||||
static void _rar_dos_date_to_text(int dos_time, char *date_string);
|
||||
static void _rar_dos_date_to_text(unsigned dos_time, char *date_string);
|
||||
/* }}} */
|
||||
|
||||
/* {{{ Functions with external linkage */
|
||||
@@ -137,7 +137,7 @@ void _rar_entry_to_zval(zval *parent,
|
||||
char *redir_target = NULL;
|
||||
size_t redir_target_size;
|
||||
|
||||
zend_update_property_long(rar_class_entry_ptr, object,
|
||||
zend_update_property_bool(rar_class_entry_ptr, object,
|
||||
"redir_to_directory", sizeof("redir_to_directory") - 1,
|
||||
!!entry->DirTarget TSRMLS_CC);
|
||||
|
||||
@@ -234,17 +234,22 @@ static zval *_rar_entry_get_property(zval *entry_obj, char *name, int namelen TS
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void _rar_dos_date_to_text(int dos_time, char *date_string) /* {{{ */
|
||||
static void _rar_dos_date_to_text(unsigned dos_time, char *date_string) /* {{{ */
|
||||
{
|
||||
int second, minute, hour, day, month, year;
|
||||
/* following lines were taken from timefn.cpp */
|
||||
second = (dos_time & 0x1f)*2;
|
||||
minute = (dos_time>>5) & 0x3f;
|
||||
hour = (dos_time>>11) & 0x1f;
|
||||
day = (dos_time>>16) & 0x1f;
|
||||
month = (dos_time>>21) & 0x0f;
|
||||
year = (dos_time>>25)+1980;
|
||||
sprintf(date_string, "%u-%02u-%02u %02u:%02u:%02u", year, month, day, hour, minute, second);
|
||||
time_t time = 0;
|
||||
struct tm tm = {0};
|
||||
int res;
|
||||
|
||||
res = rar_dos_time_convert(dos_time, &time) != FAILURE &&
|
||||
php_gmtime_r(&time, &tm) != NULL;
|
||||
|
||||
if (!res) {
|
||||
sprintf(date_string, "%s", "time conversion failure");
|
||||
}
|
||||
|
||||
sprintf(date_string, "%u-%02u-%02u %02u:%02u:%02u",
|
||||
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min,
|
||||
tm.tm_sec);
|
||||
}
|
||||
/* }}} */
|
||||
/* }}} */
|
||||
|
||||
53
tests/107.phpt
Normal file
53
tests/107.phpt
Normal file
@@ -0,0 +1,53 @@
|
||||
--TEST--
|
||||
Redirection functions
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded("rar")) die("skip");
|
||||
--FILE--
|
||||
<?php
|
||||
$m = array(
|
||||
RarEntry::FSREDIR_UNIXSYMLINK => 'FSREDIR_UNIXSYMLINK',
|
||||
RarEntry::FSREDIR_WINSYMLINK => 'FSREDIR_WINSYMLINK',
|
||||
RarEntry::FSREDIR_JUNCTION => 'FSREDIR_JUNCTION',
|
||||
RarEntry::FSREDIR_HARDLINK => 'FSREDIR_HARDLINK',
|
||||
RarEntry::FSREDIR_FILECOPY => 'FSREDIR_FILECOPY',
|
||||
);
|
||||
$a = rar_open(dirname(__FILE__) . '/rar5-links.rar');
|
||||
$i = 0;
|
||||
foreach ($a as $e) {
|
||||
if ($i++ != 0) echo "\n";
|
||||
echo "$i. ", $e->getName(), "\n";
|
||||
$type = $e->getRedirType();
|
||||
$type = $type ? $m[$type] : $type;
|
||||
echo "redir type: ", var_export($type, true), "\n";
|
||||
echo "redir to dir: ", var_export($e->isRedirectToDirectory(), true), "\n";
|
||||
echo "redir target: ", var_export($e->getRedirTarget(), true), "\n";
|
||||
// break;
|
||||
}
|
||||
echo "Done.\n";
|
||||
--EXPECTF--
|
||||
1. file1-hardlink.txt
|
||||
redir type: NULL
|
||||
redir to dir: NULL
|
||||
redir target: NULL
|
||||
|
||||
2. file1.txt
|
||||
redir type: 'FSREDIR_HARDLINK'
|
||||
redir to dir: false
|
||||
redir target: 'file1-hardlink.txt'
|
||||
|
||||
3. dir-link
|
||||
redir type: 'FSREDIR_UNIXSYMLINK'
|
||||
redir to dir: true
|
||||
redir target: 'dir'
|
||||
|
||||
4. file1-link.txt
|
||||
redir type: 'FSREDIR_UNIXSYMLINK'
|
||||
redir to dir: false
|
||||
redir target: 'file1.txt'
|
||||
|
||||
5. dir
|
||||
redir type: NULL
|
||||
redir to dir: NULL
|
||||
redir target: NULL
|
||||
Done.
|
||||
14
tests/108.phpt
Normal file
14
tests/108.phpt
Normal file
@@ -0,0 +1,14 @@
|
||||
--TEST--
|
||||
RarEntry::getPackedSize()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded("rar")) die("skip");
|
||||
--FILE--
|
||||
<?php
|
||||
$a = rar_open(dirname(__FILE__) . '/4mb.rar');
|
||||
$e = $a->getEntry('4mb.txt');
|
||||
var_dump($e->getPackedSize());
|
||||
echo "Done.\n";
|
||||
--EXPECTF--
|
||||
int(2444)
|
||||
Done.
|
||||
16
tests/109.phpt
Normal file
16
tests/109.phpt
Normal file
@@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
RarEntry::getHostOs()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded("rar")) die("skip");
|
||||
--FILE--
|
||||
<?php
|
||||
$a = rar_open(dirname(__FILE__) . '/4mb.rar');
|
||||
$e = $a->getEntry('4mb.txt');
|
||||
var_dump($e->getHostOs());
|
||||
var_dump(RarEntry::HOST_WIN32);
|
||||
echo "Done.\n";
|
||||
--EXPECTF--
|
||||
int(2)
|
||||
int(2)
|
||||
Done.
|
||||
14
tests/110.phpt
Normal file
14
tests/110.phpt
Normal file
@@ -0,0 +1,14 @@
|
||||
--TEST--
|
||||
RarEntry::getFileTime()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded("rar")) die("skip");
|
||||
--FILE--
|
||||
<?php
|
||||
$a = rar_open(dirname(__FILE__) . '/4mb.rar');
|
||||
$e = $a->getEntry('4mb.txt');
|
||||
var_dump($e->getFileTime());
|
||||
echo "Done.\n";
|
||||
--EXPECTF--
|
||||
string(19) "2010-05-30 01:22:00"
|
||||
Done.
|
||||
14
tests/111.phpt
Normal file
14
tests/111.phpt
Normal file
@@ -0,0 +1,14 @@
|
||||
--TEST--
|
||||
RarEntry::getVersion()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded("rar")) die("skip");
|
||||
--FILE--
|
||||
<?php
|
||||
$a = rar_open(dirname(__FILE__) . '/rar5-links.rar');
|
||||
$e = $a->getEntry('file1.txt');
|
||||
var_dump($e->getVersion());
|
||||
echo "Done.\n";
|
||||
--EXPECTF--
|
||||
int(200)
|
||||
Done.
|
||||
14
tests/112.phpt
Normal file
14
tests/112.phpt
Normal file
@@ -0,0 +1,14 @@
|
||||
--TEST--
|
||||
RarEntry::getMethod()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded("rar")) die("skip");
|
||||
--FILE--
|
||||
<?php
|
||||
$a = rar_open(dirname(__FILE__) . '/rar5-links.rar');
|
||||
$e = $a->getEntry('file1.txt');
|
||||
var_dump($e->getMethod());
|
||||
echo "Done.\n";
|
||||
--EXPECTF--
|
||||
int(48)
|
||||
Done.
|
||||
19
tests/113.phpt
Normal file
19
tests/113.phpt
Normal file
@@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
RarEntry::isEncrypted()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded("rar")) die("skip");
|
||||
--FILE--
|
||||
<?php
|
||||
$a = rar_open(dirname(__FILE__) . '/rar5-links.rar');
|
||||
$e = $a->getEntry('file1.txt');
|
||||
var_dump($e->isEncrypted());
|
||||
|
||||
$a = rar_open(dirname(__FILE__) . '/encrypted_only_files.rar');
|
||||
$e = $a->getEntry('encfile1.txt');
|
||||
var_dump($e->isEncrypted());
|
||||
echo "Done.\n";
|
||||
--EXPECTF--
|
||||
bool(false)
|
||||
bool(true)
|
||||
Done.
|
||||
BIN
tests/rar5-links.rar
Normal file
BIN
tests/rar5-links.rar
Normal file
Binary file not shown.
Reference in New Issue
Block a user