File_Operation class

From: Date: Fri, 27 Jul 2001 23:06:27 +0000
Subject: File_Operation class
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-1098@lists.php.net to get a copy of this message
I had the task of writing a cron script which would delete files older than some days to clean up the oracle archive log on a server which getts filled up after a few months. Instead of spending 10 minutes to write a basic shell script I went and wrote a File_Operation class for pear. I think it's gonna be useful for shell scripts and can be used from the web too. It processes a bunch of files, it has criteria and action. Criteria can be any of the following OLDER|NEWER ( both have support for days, minutes and seconds), BIGGER|SMALLER( supports KB, MB, GB), NAME_LIKE|NAME_NOT_LIKE and EREG|NOT_EREG. Operation can be DELETE|TOUCH|MOVE|CHANAGEPERMISSIONS with COMPRESS|ENCODE|ENCRYPT planned in v2. I'm not sure if the name sounds right for it. It's partly finished now. Most of the things are finished and I wanted some feedback from you guys. It can be used with the File_Find class. Here is an example of usage. ex: <?php include("File/Operation.php"); include("File/Find.php"); function errorFunc($err){ print($err->getMessage()); die(); } PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'errorFunc'); $filefind = new File_Find(); $files = $filefind->maptree("c:/temp/"); $op = new File_Operation(); $op->debug = true; $op->run(&$files[1], FILE_CRITERIA_OLDER_, "10MB" , FILE_OPERATION_); print_r($op->failed_reasons); ?> yavor shahpasov The difference between a good man and a bad one is the choice of cause - William James

« previous php.pear.dev (#1098) next »