php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57615 extract leaves a file descriptor
Submitted: 2007-04-08 09:19 UTC Modified: 2007-04-08 09:37 UTC
From: YLQUFHWNNUYL at spammotel dot com Assigned:
Status: Not a bug Package: rar (PECL)
PHP Version: 5.2.1 OS: win32
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: YLQUFHWNNUYL at spammotel dot com
New email:
PHP Version: OS:

 

 [2007-04-08 09:19 UTC] YLQUFHWNNUYL at spammotel dot com
Description:
------------
i'm using the newest win32 binaries from the php.net PECL package.
whenever i use extract, two file descriptors are opened, but only one gets closed by rar_close(), so it keeps one open for the archive for each time extract was called i believe...

this maybe just a problem with the compile for win32, or rar_close missing something...



--tacking on a feature request:
i believe this extension really needs the ability to get the file with some other way than extract... such as some way to be able to directly stream the file to something else
I'm using your extension to be able to download single files out of rar files i have stored, but the best way i've found to do it is extract to $tmpfile, then
$tosend = file_get_contents($tmpfile);
unlink($tmpfile);
//start sending file

So it would be really nice to be able to load the extracted file into a string or something...


--side note
i'll probably post my script to the php.net page about your extension, to help anyone at all interested in this extension with their code

Reproduce code:
---------------
$rar_file = rar_open($path.'/'.$file) or die("Can't open Rar archive");

$entry = rar_entry_get($rar_file, $fname) or die("Failed to find such entry");
$tmpfile=$path.'/tmp/file.tmp';
if ($entry->extract(false, $tmpfile)) {
///operations
}
rar_close($rar_file);


//or examples on the extract page (which one is missing even rar_close)

Expected result:
----------------
for it to open the rar file, then close all references to it, but it seems extract opens another reference which does not get closed... no matter what i do.

i'm seeing the open file list with a program called TaskInfo, but any advanced task manager probably could list them for someone

I don't know if there is any way to close the files by force in php because i'm fairly new to it... and don't know a way to reference that file anyways.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-08 09:37 UTC] tony2001 at phpclub dot net
>two file descriptors are opened, but only one gets closed by rar_close()
PECL/rar just uses unrar API, it doesn't open/close any files directly.
So if something goes wrong on a low level, this most likely means a problem in unrar.

>i believe this extension really needs the ability to get
>the file with some other way than extract..
Same here.
We're limited to the existing API of unrar.
It doesn't provide any way to get a stream, so we don't have much choice.

>i'll probably post my script to the php.net page about your extension
If the script is really helpful, I may consider adding it to the documentation, so feel free to send the script to me.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 07:01:29 2024 UTC