views:

52

answers:

1

I have a script that's gonna check a zipfile containing a number of matching PDF+textfiles. I want to unpack or somehow read the textfiles from the zipfile and just pick out some information from the textfile to see that the file version is correct.

I was looking at the tempnam function to find an equivalent to make an tempdir, but maybe someone has a better solution for the problem.

The indexfile looks something like this. -> is for TAB char. I have made the function to extract the version from the textfile and to check if its correct already, its only the unpacking, tmpdir or some other solution im looking for.

1000->filename->file version->program version->customer no->company no->distribution
2000->pagenumber->more info->more info-> and so on....
+2  A: 

Hi there,

quite easy (I took partly it from the PHP manual ;) ):

<?php

function tempdir($dir=false,$prefix='php') {
    $tempfile=tempnam(sys_get_temp_dir(),'');
    if (file_exists($tempfile)) { unlink($tempfile); }
    mkdir($tempfile);
    if (is_dir($tempfile)) { return $tempfile; }
}

/*example*/

echo tempdir();
// returns: /tmp/8e9MLi

See: http://de.php.net/manual/en/function.tempnam.php

Remember, that in a linux system a file and a directory are theoretically the same thing. Watch out on a windows system ;)

Mario Mueller