Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #14352 > unrolled thread

unzio without directory

Started byJan Novak <repcom@gmail.com>
First post2014-10-15 09:30 +0200
Last post2014-10-27 13:36 +0100
Articles 13 — 3 participants

Back to article view | Back to comp.lang.php


Contents

  unzio without directory Jan Novak <repcom@gmail.com> - 2014-10-15 09:30 +0200
    Re: unzio without directory Jerry Stuckle <jstucklex@attglobal.net> - 2014-10-15 06:18 -0400
      Re: unzio without directory Jan Novak <repcom@gmail.com> - 2014-10-15 12:54 +0200
        Re: unzio without directory Jerry Stuckle <jstucklex@attglobal.net> - 2014-10-15 12:17 -0400
    unzip without extracting directory (was: unzio without directory) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-16 04:00 +0200
      Re: unzip without extracting directory Jerry Stuckle <jstucklex@attglobal.net> - 2014-10-15 22:06 -0400
        Re: unzip without extracting directory Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-23 05:57 +0200
          Re: unzip without extracting directory Jan Novak <repcom@gmail.com> - 2014-10-23 08:32 +0200
            Re: unzip without extracting directory Jerry Stuckle <jstucklex@attglobal.net> - 2014-10-23 05:56 -0400
          Re: unzip without extracting directory Jerry Stuckle <jstucklex@attglobal.net> - 2014-10-23 05:55 -0400
            Re: unzip without extracting directory Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-23 18:44 +0200
              Re: unzip without extracting directory Jerry Stuckle <jstucklex@attglobal.net> - 2014-10-23 20:10 -0400
                Re: unzip without extracting directory Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-27 13:36 +0100

#14352 — unzio without directory

FromJan Novak <repcom@gmail.com>
Date2014-10-15 09:30 +0200
Subjectunzio without directory
Message-ID<m1l7sb$3fa$1@news.albasani.net>
Hi,
i have this code for unzipping:


$file = $fileName;
$path = pathinfo(realpath($file), PATHINFO_DIRNAME);
$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE) {
	$zip->extractTo($path);
	$zip->close();
	echo "OK";
} else {
	echo "Fail";
}

This works fine - but the zip file contains a directory structure like this:

RootDirectoryDir0
	File1
	File2	
	...
	<Dir1>
		File1
		...
	<Dir2>
		File1
		...

I want only everything without Dir0. So that i get files like this:
	File1
	File2	
	...
	<Dir1>
		File1
		...
	<Dir2>
		File1
		...



Jan

[toc] | [next] | [standalone]


#14353

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-10-15 06:18 -0400
Message-ID<m1lhlb$r1v$1@dont-email.me>
In reply to#14352
On 10/15/2014 3:30 AM, Jan Novak wrote:
> Hi,
> i have this code for unzipping:
> 
> 
> $file = $fileName;
> $path = pathinfo(realpath($file), PATHINFO_DIRNAME);
> $zip = new ZipArchive;
> $res = $zip->open($file);
> if ($res === TRUE) {
>     $zip->extractTo($path);
>     $zip->close();
>     echo "OK";
> } else {
>     echo "Fail";
> }
> 
> This works fine - but the zip file contains a directory structure like
> this:
> 
> RootDirectoryDir0
>     File1
>     File2   
>     ...
>     <Dir1>
>         File1
>         ...
>     <Dir2>
>         File1
>         ...
> 
> I want only everything without Dir0. So that i get files like this:
>     File1
>     File2   
>     ...
>     <Dir1>
>         File1
>         ...
>     <Dir2>
>         File1
>         ...
> 
> 
> 
> Jan

Unzip to a temporary directory then move everything to where you want it.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#14354

FromJan Novak <repcom@gmail.com>
Date2014-10-15 12:54 +0200
Message-ID<m1ljq3$qub$1@news.albasani.net>
In reply to#14353


Am 15.10.2014 um 12:18 schrieb Jerry Stuckle:
>> I want only everything without Dir0. So that i get files like this:
>>      File1
>>      File2
>>      ...
>>      <Dir1>
>>          File1
>>          ...
>>      <Dir2>
>>          File1
>>          ...
> Unzip to a temporary directory then move everything to where you want it.

OK, this may also be a soltution.
I think, i have not ask my problem behind this question.

I like to have a upgrade mechanism, who will overwrite the php files.
But what i see is: how can i check every file/directory rights ?
Maybe i must in the future vreate Directorys or modify them also with files.

What can be the best proceed for that?

Jan

[toc] | [prev] | [next] | [standalone]


#14355

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-10-15 12:17 -0400
Message-ID<m1m6n4$72v$1@dont-email.me>
In reply to#14354
On 10/15/2014 6:54 AM, Jan Novak wrote:
> 
> 
> 
> Am 15.10.2014 um 12:18 schrieb Jerry Stuckle:
>>> I want only everything without Dir0. So that i get files like this:
>>>      File1
>>>      File2
>>>      ...
>>>      <Dir1>
>>>          File1
>>>          ...
>>>      <Dir2>
>>>          File1
>>>          ...
>> Unzip to a temporary directory then move everything to where you want it.
> 
> OK, this may also be a soltution.
> I think, i have not ask my problem behind this question.
> 
> I like to have a upgrade mechanism, who will overwrite the php files.
> But what i see is: how can i check every file/directory rights ?
> Maybe i must in the future vreate Directorys or modify them also with
> files.
> 
> What can be the best proceed for that?
> 
> Jan

You have to check the rights individually for each directory.  But be
forewarned, if you're doing this through a web server, the web server
should NOT have write access to the PHP files (ideally, it shouldn't
even have write access to any files/directories except those which have
been uploaded through the web server, i.e. files for download by other
users).

If you're using the CLI instead, you need to ensure the user you are
running as has write access to the files and directories in question.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#14357 — unzip without extracting directory (was: unzio without directory)

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-10-16 04:00 +0200
Subjectunzip without extracting directory (was: unzio without directory)
Message-ID<3921955.eAtPLq5odn@PointedEars.de>
In reply to#14352
Jan Novak wrote:

> i have this code for unzipping:
> 
> 
> $file = $fileName;

This is pointless.  Why not use $fileName in the following?

> $path = pathinfo(realpath($file), PATHINFO_DIRNAME);
> $zip = new ZipArchive;
> $res = $zip->open($file);
> if ($res === TRUE) {
> $zip->extractTo($path);
> $zip->close();
> echo "OK";
> } else {
> echo "Fail";
> }
> 
> This works fine - but the zip file contains a directory structure like
> this:
> […]
> I want only everything without Dir0. So that i get files like this:
> […]

That is not a question, and you have been negligent with your Subject header 
field value, too: <http://www.catb.org/~esr/faqs/smart-questions.html>

Next time, RTFM first (took me less than 10 seconds to find it):

<http://php.net/manual/en/ziparchive.extractto.php#100802>
 
-- 
PointedEars
Zend Certified PHP Engineer
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#14358 — Re: unzip without extracting directory

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-10-15 22:06 -0400
SubjectRe: unzip without extracting directory
Message-ID<m1n970$fud$1@dont-email.me>
In reply to#14357
On 10/15/2014 10:00 PM, Thomas 'PointedEars' Lahn wrote:
> Jan Novak wrote:
> 
>> i have this code for unzipping:
>>
>>
>> $file = $fileName;
> 
> This is pointless.  Why not use $fileName in the following?
>

Because she's not a pedantic troll, that's why.

>> $path = pathinfo(realpath($file), PATHINFO_DIRNAME);
>> $zip = new ZipArchive;
>> $res = $zip->open($file);
>> if ($res === TRUE) {
>> $zip->extractTo($path);
>> $zip->close();
>> echo "OK";
>> } else {
>> echo "Fail";
>> }
>>
>> This works fine - but the zip file contains a directory structure like
>> this:
>> […]
>> I want only everything without Dir0. So that i get files like this:
>> […]
> 
> That is not a question, and you have been negligent with your Subject header 
> field value, too: <http://www.catb.org/~esr/faqs/smart-questions.html>
> 
> Next time, RTFM first (took me less than 10 seconds to find it):
> 
> <http://php.net/manual/en/ziparchive.extractto.php#100802>
>  
> 

Maybe if you understood ANYTHING you would understand this does NOT
resolve her problem.  But you don't - as usua.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#14371 — Re: unzip without extracting directory

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-10-23 05:57 +0200
SubjectRe: unzip without extracting directory
Message-ID<4568324.GT5VcWPXNi@PointedEars.de>
In reply to#14358
Jerry Stuckle wrote:

> On 10/15/2014 10:00 PM, Thomas 'PointedEars' Lahn wrote:
>> Jan Novak wrote:
>>> $path = pathinfo(realpath($file), PATHINFO_DIRNAME);
>>> $zip = new ZipArchive;
>>> $res = $zip->open($file);
>>> if ($res === TRUE) {
>>> $zip->extractTo($path);
>>> $zip->close();
>>> echo "OK";
>>> } else {
>>> echo "Fail";
>>> }
>>>
>>> This works fine - but the zip file contains a directory structure like
>>> this:
>>> […]
>>> I want only everything without Dir0. So that i get files like this:
>>> […]
>> 
>> Next time, RTFM first (took me less than 10 seconds to find it):
>> 
>> <http://php.net/manual/en/ziparchive.extractto.php#100802>
> 
> Maybe if you understood ANYTHING you would understand this does NOT
> resolve her problem. 

Wrong.  This is not a repository for complete solutions.  I am and I have 
been fully aware that the code there needs only a *slight* adaptation to do 
*exactly* what the OP is looking for.  Do you know which?

BTW, Jan is a *male* given name; not to be confused with, e.g. Jana or Jane.

-- 
PointedEars
Zend Certified PHP Engineer
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#14372 — Re: unzip without extracting directory

FromJan Novak <repcom@gmail.com>
Date2014-10-23 08:32 +0200
SubjectRe: unzip without extracting directory
Message-ID<m2a7ev$sot$1@news.albasani.net>
In reply to#14371
Am 23.10.2014 um 05:57 schrieb Thomas 'PointedEars' Lahn:
>
> BTW, Jan is a *male* given name; not to be confused with, e.g. Jana or Jane.
>

Doesn't matter, im thankful for every help.
And he has helped me with his post :-)

Jan

[toc] | [prev] | [next] | [standalone]


#14375 — Re: unzip without extracting directory

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-10-23 05:56 -0400
SubjectRe: unzip without extracting directory
Message-ID<m2ajbs$kqu$2@dont-email.me>
In reply to#14372
On 10/23/2014 2:32 AM, Jan Novak wrote:
> Am 23.10.2014 um 05:57 schrieb Thomas 'PointedEars' Lahn:
>>
>> BTW, Jan is a *male* given name; not to be confused with, e.g. Jana or
>> Jane.
>>
> 
> Doesn't matter, im thankful for every help.
> And he has helped me with his post :-)
> 
> Jan

Sorry about that - I've known several female Jans over the years, also.
 More than male, in fact.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#14374 — Re: unzip without extracting directory

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-10-23 05:55 -0400
SubjectRe: unzip without extracting directory
Message-ID<m2ajae$kqu$1@dont-email.me>
In reply to#14371
On 10/22/2014 11:57 PM, Thomas 'PointedEars' Lahn wrote:
> Jerry Stuckle wrote:
> 
>> On 10/15/2014 10:00 PM, Thomas 'PointedEars' Lahn wrote:
>>> Jan Novak wrote:
>>>> $path = pathinfo(realpath($file), PATHINFO_DIRNAME);
>>>> $zip = new ZipArchive;
>>>> $res = $zip->open($file);
>>>> if ($res === TRUE) {
>>>> $zip->extractTo($path);
>>>> $zip->close();
>>>> echo "OK";
>>>> } else {
>>>> echo "Fail";
>>>> }
>>>>
>>>> This works fine - but the zip file contains a directory structure like
>>>> this:
>>>> […]
>>>> I want only everything without Dir0. So that i get files like this:
>>>> […]
>>>
>>> Next time, RTFM first (took me less than 10 seconds to find it):
>>>
>>> <http://php.net/manual/en/ziparchive.extractto.php#100802>
>>
>> Maybe if you understood ANYTHING you would understand this does NOT
>> resolve her problem. 
> 
> Wrong.  This is not a repository for complete solutions.  I am and I have 
> been fully aware that the code there needs only a *slight* adaptation to do 
> *exactly* what the OP is looking for.  Do you know which?
> 

Sure this is the right place for a complete solution.  But YOU don't
know what it is, that is obvious.  I gave a much better solution.  You
gave crap - as usual.

> BTW, Jan is a *male* given name; not to be confused with, e.g. Jana or Jane.
> 

BTW - Jan is also a female name - usually short for Janet.  But once
again you show your stoopidity.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#14377 — Re: unzip without extracting directory

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-10-23 18:44 +0200
SubjectRe: unzip without extracting directory
Message-ID<2355890.eN34QP5rFt@PointedEars.de>
In reply to#14374
Jerry Stuckle wrote:

> On 10/22/2014 11:57 PM, Thomas 'PointedEars' Lahn wrote:
>> Jerry Stuckle wrote:
>>> On 10/15/2014 10:00 PM, Thomas 'PointedEars' Lahn wrote:
>>>> Jan Novak wrote:
>>>>> […] the zip file contains a directory structure like this:
>>>>> […]
>>>>> I want only everything without Dir0. So that i get files like this:
>>>>> […]
>>>> Next time, RTFM first (took me less than 10 seconds to find it):
>>>>
>>>> <http://php.net/manual/en/ziparchive.extractto.php#100802>
>>> Maybe if you understood ANYTHING you would understand this does NOT
>>> resolve her problem.
>> 
>> Wrong.  This is not a repository for complete solutions.  I am and I have
>> been fully aware that the code there needs only a *slight* adaptation to
>> do *exactly* what the OP is looking for.  Do you know which?
> 
> Sure this is the right place for a complete solution

Usenet is not a right.  If *you* want to post a complete solution, you are 
free to do so.  But anyone asking here has not a right to get one, so one is 
free not to provide one.  In fact, it is better to teach a man how to fish, 
and because of that, Usenet, and developer forums in general, usually work 
*that* way.

<http://www.catb.org/~esr/faqs/smart-questions.html>

> But YOU don't know what it is, that is obvious.

I have already written that I do.  I have tested it positive.  You have not 
answered my question, though, so probably you do not know the answer.

> I gave a much better solution. [abuse snipped]

You have suggested, in words, but not at all in code, to extract to a 
temporary directory and then move all files under the contained directory.   
In which way is that “much better” than extracting the files (including the 
directories) under the contained directory directly?


PointedEars
-- 
PointedEars
Zend Certified PHP Engineer
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#14382 — Re: unzip without extracting directory

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-10-23 20:10 -0400
SubjectRe: unzip without extracting directory
Message-ID<m2c5ea$a4t$1@dont-email.me>
In reply to#14377
On 10/23/2014 12:44 PM, Thomas 'PointedEars' Lahn wrote:
> Jerry Stuckle wrote:
> 
>> On 10/22/2014 11:57 PM, Thomas 'PointedEars' Lahn wrote:
>>> Jerry Stuckle wrote:
>>>> On 10/15/2014 10:00 PM, Thomas 'PointedEars' Lahn wrote:
>>>>> Jan Novak wrote:
>>>>>> […] the zip file contains a directory structure like this:
>>>>>> […]
>>>>>> I want only everything without Dir0. So that i get files like this:
>>>>>> […]
>>>>> Next time, RTFM first (took me less than 10 seconds to find it):
>>>>>
>>>>> <http://php.net/manual/en/ziparchive.extractto.php#100802>
>>>> Maybe if you understood ANYTHING you would understand this does NOT
>>>> resolve her problem.
>>>
>>> Wrong.  This is not a repository for complete solutions.  I am and I have
>>> been fully aware that the code there needs only a *slight* adaptation to
>>> do *exactly* what the OP is looking for.  Do you know which?
>>
>> Sure this is the right place for a complete solution
> 
> Usenet is not a right.  If *you* want to post a complete solution, you are 
> free to do so.  But anyone asking here has not a right to get one, so one is 
> free not to provide one.  In fact, it is better to teach a man how to fish, 
> and because of that, Usenet, and developer forums in general, usually work 
> *that* way.
> 
> <http://www.catb.org/~esr/faqs/smart-questions.html>
> 
>> But YOU don't know what it is, that is obvious.
> 
> I have already written that I do.  I have tested it positive.  You have not 
> answered my question, though, so probably you do not know the answer.

You're the one who claimed you had an answer.  And not it becomes even
more obvious you are just trolling (again).

> 
>> I gave a much better solution. [abuse snipped]
>
> You have suggested, in words, but not at all in code, to extract to a 
> temporary directory and then move all files under the contained directory.   
> In which way is that “much better” than extracting the files (including the 
> directories) under the contained directory directly?
> 

Which is the correct answer.  But you still don't understand the
question, so there is no way you can provide an answer.

> 
> PointedEars
> 

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#14413 — Re: unzip without extracting directory

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-10-27 13:36 +0100
SubjectRe: unzip without extracting directory
Message-ID<2502445.CBHX9Wh9Va@PointedEars.de>
In reply to#14382
Jerry Stuckle wrote:

> On 10/23/2014 12:44 PM, Thomas 'PointedEars' Lahn wrote:
>> Jerry Stuckle wrote:
>>> I gave a much better solution. [abuse snipped]
>>
>> You have suggested, in words, but not at all in code, to extract to a
>> temporary directory and then move all files under the contained
>> directory. In which way is that “much better” than extracting the files
>> (including the directories) under the contained directory directly?
> 
> Which is the correct answer.

There is not *the* *single*, correct, answer here.  There are *several* ways 
in which the posed problem can be approached; there are at least two.  You 
have suggested a different approach than I did (again, I am fully aware that 
the code I have referred to does not, *as it is*, solve the problem; it is a 
good start though).  Fair enough.  I have asked you above in which way you 
think your approach is better.  You have still not answered that question.

Do you even have *solid* arguments *why* your approach is the better one?

> But you still don't understand the question,

How did you get that idea?

> so there is no way you can provide an answer.

Ex falso quodlibet.
 
-- 
PointedEars
Zend Certified PHP Engineer
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web